UNPKG

mylingo3d

Version:

Lingo3D is a React/Vue 3d game development framework that ships with a complete visual editor

61 lines (51 loc) 1.2 kB
import { Camera, Cube, keyboard, settings, Sky } from ".." const sky = new Sky() const floor = new Cube() floor.width = 9999 floor.depth = 9999 floor.y = -100 floor.physics = true floor.mass = 0 floor.opacity = 0.5 const cam = new Camera() cam.active = true cam.mouseControl = true cam.physics = true cam.noTumble = true cam.height = 200 keyboard.onKeyPress = (key) => { if (key === " ") cam.applyImpulse(0, 10, 0) if (key === "w") cam.moveForward(10) if (key === "s") cam.moveForward(-10) if (key === "a") cam.moveRight(-10) if (key === "d") cam.moveRight(10) } const block2 = new Cube() block2.z = -300 block2.physics = true block2.opacity = 0.5 block2.id = "block" const block = new Cube() block.z = -500 block.physics = true block.opacity = 0.5 block.id = "block" block.onMouseOver = () => { block.color = "red" } block.onMouseOut = () => { block.color = "white" } // cam.onLoop = () => { // console.log(block.frustumVisible) // block.color = "white" // block2.color = "white" // const blocks = cam.getRayIntersections<Cube>("block") // if (blocks.length) // blocks[0].color = "red" // }