Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getHighlightMesh(rendering) {
var m = rendering._highlightMesh
if (!m) {
var mesh = Mesh.CreatePlane("highlight", 1.0, rendering._scene)
var hlm = rendering.makeStandardMaterial('highlightMat')
hlm.backFaceCulling = false
hlm.emissiveColor = new Color3(1, 1, 1)
hlm.alpha = 0.2
mesh.material = hlm
m = rendering._highlightMesh = mesh
// outline
var s = 0.5
var lines = Mesh.CreateLines("hightlightLines", [
new Vector3(s, s, 0),
new Vector3(s, -s, 0),
new Vector3(-s, -s, 0),
new Vector3(-s, s, 0),
new Vector3(s, s, 0)
], rendering._scene)
lines.color = new Color3(1, 1, 1)
scene.detachControl()
// octree setup
self._octree = new Octree($ => {})
self._octree.blocks = []
scene._selectionOctree = self._octree
// camera, and empty mesh to hold it, and one to accumulate rotations
self._cameraHolder = new Mesh('camHolder', scene)
self._camera = new FreeCamera('camera', new Vector3(0, 0, 0), scene)
self._camera.parent = self._cameraHolder
self._camera.minZ = .01
self._cameraHolder.visibility = false
// plane obscuring the camera - for overlaying an effect on the whole view
self._camScreen = Mesh.CreatePlane('camScreen', 10, scene)
self.addMeshToScene(self._camScreen)
self._camScreen.position.z = .1
self._camScreen.parent = self._camera
self._camScreenMat = self.makeStandardMaterial('camscreenmat')
self._camScreen.material = self._camScreenMat
self._camScreen.setEnabled(false)
self._camLocBlock = 0
// apply some defaults
var lightVec = new Vector3(0.1, 1, 0.3)
self._light = new HemisphericLight('light', lightVec, scene)
function arrToColor(a) { return new Color3(a[0], a[1], a[2]) }
scene.clearColor = arrToColor(opts.clearColor)
scene.ambientColor = arrToColor(opts.ambientColor)
self._light.diffuse = arrToColor(opts.lightDiffuse)