Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function onControlAdded (button3d) {
if (button3d.hostInstance && button3d.hostInstance.mesh && button3d.hostInstance.mesh.material) {
// the material is only available after attaching to BabylonJS host (3D GUI)
const material = button3d.hostInstance.mesh.material
material.diffuseColor = Color3.Black()
button3d.hostInstance.pointerEnterAnimation = () => {
material.emissiveColor = Color3.FromInts(15, 15, 15)
}
button3d.hostInstance.pointerOutAnimation = () => {
material.emissiveColor = Color3.Black()
}
} else {
console.error('onControlAdded(): no host instance -> mesh -> material', button3d)
}
}
export default function (noa, dist) {
var shadowDist = dist
// create a mesh to re-use for shadows
var scene = noa.rendering.getScene()
var disc = Mesh.CreateDisc('shadow', 0.75, 30, scene)
disc.rotation.x = Math.PI / 2
disc.material = noa.rendering.makeStandardMaterial('shadowMat')
disc.material.diffuseColor = Color3.Black()
disc.material.ambientColor = Color3.Black()
disc.material.alpha = 0.5
disc.setEnabled(false)
// source mesh needn't be in the scene graph
scene.removeMesh(disc)
return {
name: 'shadow',
order: 80,
state: {
size: 0.5,
export default function (noa, dist) {
var shadowDist = dist
// create a mesh to re-use for shadows
var scene = noa.rendering.getScene()
var disc = Mesh.CreateDisc('shadow', 0.75, 30, scene)
disc.rotation.x = Math.PI / 2
disc.material = noa.rendering.makeStandardMaterial('shadowMat')
disc.material.diffuseColor = Color3.Black()
disc.material.ambientColor = Color3.Black()
disc.material.alpha = 0.5
disc.setEnabled(false)
// source mesh needn't be in the scene graph
scene.removeMesh(disc)
return {
name: 'shadow',
order: 80,
state: {
size: 0.5,
_mesh: null,
let baseUrl = 'https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/'
return (
this.props.onModelLoaded(model, this.props.sceneContext)
}
}}
position={this.props.center}
rootUrl={this.props.rootUrl}
sceneFilename={this.props.sceneFilename}
pluginExtension={this.props.fileExtension}
rotation={this.props.modelRotation}
/>
{(this.state.loadProgress < 1) &&
}
)
}
}
.add('Drag and Drop', () => (
button3d.hostInstance.pointerOutAnimation = () => {
material.emissiveColor = Color3.Black()
}
} else {
this.getItems(`https://api.remix3d.com/v3/boards/${result.item.id}`, 'boards', this.state.headers)
} else if (result.type === 'creation') {
this.loadCreation(result.item)
}
}}
/>
)
} else {
return null
}
})
}