add selected / unselected visual states
This commit is contained in:
parent
86b60cc715
commit
f3403ebe5c
3 changed files with 39 additions and 5 deletions
|
|
@ -16,13 +16,20 @@ let mesh = self.mesh = self.mesh || {};
|
|||
if (mesh.model) return;
|
||||
|
||||
/** default materials **/
|
||||
mesh.material = {
|
||||
solid: new THREE.MeshPhongMaterial({
|
||||
let materials = mesh.material = {
|
||||
unselected: new THREE.MeshPhongMaterial({
|
||||
transparent: true,
|
||||
shininess: 100,
|
||||
specular: 0x181818,
|
||||
color: 0xffff00,
|
||||
opacity: 1
|
||||
}),
|
||||
selected: new THREE.MeshPhongMaterial({
|
||||
transparent: true,
|
||||
shininess: 100,
|
||||
specular: 0x181818,
|
||||
color: 0x00ff00,
|
||||
opacity: 1
|
||||
})
|
||||
};
|
||||
|
||||
|
|
@ -50,7 +57,7 @@ mesh.model = class MeshModel extends mesh.object {
|
|||
if (indices) geo.setIndex(new THREE.BufferAttribute(indices, 1));
|
||||
geo.setAttribute('position', new THREE.BufferAttribute(vertices, 3));
|
||||
geo.setAttribute('normal', undefined);
|
||||
let meh = new THREE.Mesh(geo, mesh.material.solid);
|
||||
let meh = new THREE.Mesh(geo, materials.unselected);
|
||||
geo.computeFaceNormals();
|
||||
geo.computeVertexNormals();
|
||||
meh.material.side = THREE.DoubleSide;
|
||||
|
|
@ -114,6 +121,10 @@ mesh.model = class MeshModel extends mesh.object {
|
|||
moto.Space.update();
|
||||
}
|
||||
|
||||
material(mat) {
|
||||
this.mesh.material = mat;
|
||||
}
|
||||
|
||||
remove() {
|
||||
mesh.api.model.remove(this);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue