Commit 5bf57dca authored by Arnaud Blanchard's avatar Arnaud Blanchard
Browse files

Téléverser un nouveau fichier

parent 41f1f60b
<!DOCTYPE html>
<html data-lt-installed="true"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.js"></script> -->
<script src="blc%20monitor_fichiers/jquery-3.js"></script>
<script src="blc%20monitor_fichiers/jquery-ui.js"></script>
<link rel="stylesheet" href="blc%20monitor_fichiers/jquery-ui.css">
<script type="text/javascript" src="blc%20monitor_fichiers/jquery.js"></script>
<link rel="stylesheet" href="blc%20monitor_fichiers/index.css">
<title>blc monitor</title>
<script src="blc%20monitor_fichiers/blc_channel.js" type="text/javascript"></script>
<script src="blc%20monitor_fichiers/blc_gui.js" type="text/javascript"></script>
<script src="blc%20monitor_fichiers/displays.js" type="text/javascript"></script>
<script src="blc%20monitor_fichiers/three.js" type="text/javascript"></script>
</head>
<body data-new-gr-c-s-check-loaded="8.869.0" data-gr-ext-installed="">
<h1> Swarm </h1>
<button value="send" id="send">Send </button>
<script type="text/javascript">
const W=2./Math.sqrt(3)
const H=1
class Creature{
static material
static geometry
static mesh
constructor(x, y){
this.x=x
this.y=y
}
static init(){
material = new THREE.MeshBasicMaterial({ color: 0x008000 })
geometry = new THREE.BufferGeometry().setAttribute(
'position', new THREE.BufferAttribute(
new Float32Array([
0, H*2./3., 0,
-W/2., -H*1./3.,
0, W/2.,-H*1./3.,0])
))
mesh = new THREE.Mesh( geometry, material)
}
}
class Ground{
constructor(size){
}
static material = new THREE.MeshBasicMaterial( { color: 0x000080 });
}
Creature.init()
const scene = new THREE.Scene();
const renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
const canvas=renderer.domElement ;
document.body.appendChild(canvas);
const camera = new THREE.PerspectiveCamera( 75, canvas.width / canvas.height, 0.1, 100 );
const selectedMaterial = new THREE.MeshBasicMaterial( { color: 0xff0000, side: THREE.DoubleSide } );
const floorGeometry = new THREE.BufferGeometry()
let floorVertices = new Float32Array( [
0, 10*H*2./3., 0,
-W/2.*10, -H*1./3.*10, 0,
W/2.*10 , -H*1./3.*10,0,
] )
floorGeometry.setAttribute( 'position', new THREE.BufferAttribute( floorVertices, 3 ) )
const floor = new THREE.Mesh( floorGeometry, Ground.material )
const creatures = new THREE.Group()
creatures.add( new Creature );
scene.add( floor );
scene.add( creatures);
let mouse_add=false
camera.position.z = 5;
camera.updateProjectionMatrix();
const raycaster = new THREE.Raycaster()
const mouse = new THREE.Vector2()
let intersects =[];
canvas.addEventListener( 'mousemove',(event)=>{
const rect = canvas.getBoundingClientRect();
mouse.x = ( (event.clientX-rect.left) / window.innerWidth ) * 2 - 1;
mouse.y = - (( event.clientY-rect.top) / window.innerHeight ) * 2 + 1;
}, false)
canvas.addEventListener( 'mousedown',(event)=>{
mouse_add = true;
}, false)
canvas.addEventListener( 'mouseup',(event)=>{
mouse_add = false;
}, false)
renderer.domElement.addEventListener( 'wheel', (event) => {
event.preventDefault()
event.stopPropagation()
if (event.deltaY>0 && camera.zoom<1000) camera.zoom*=1.1
else if (event.deltaY<0 && camera.zoom>0.001) camera.zoom*=0.9
camera.updateProjectionMatrix()
});
function animate() {
requestAnimationFrame( animate );
raycaster.setFromCamera( mouse, camera );
for( let intersect of intersects){
intersect.object.material=Creature.material
}
intersects = raycaster.intersectObjects( creatures.children );
for( let intersect of intersects){
intersect.object.material=selectedMaterial
}
if (mouse_add){
intersection = raycaster.intersectObject( floor );
let new_creature = creature.clone()
new_creature.position.set(intersection[0].point.x, intersection[0].point.y, 0.1)
creatures.add(new_creature)
}
//cube.rotation;
renderer.render( scene, camera );
}
animate();
</script>
</body></html>
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment