Skip to content

Commit

Permalink
#81 - emit and receive material type and shadow
Browse files Browse the repository at this point in the history
  • Loading branch information
hirako2000 committed Mar 12, 2017
1 parent 0691716 commit 82d27fe
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/whs-module-socket/experimental/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const box = new WHS.Box({
cast: false
},

material: new THREE.MeshBasicMaterial({
material: new THREE.MeshPhongMaterial({
color: 0xffffff
}),

Expand Down
22 changes: 20 additions & 2 deletions modules/whs-module-socket/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,32 @@ export default class SocketModule {
const meshes = this.meshes;

this.socket.on('new-mesh', msg => {
let material = null;
switch (msg.mesh.material.type) {
case 'MeshBasicMaterial':
material = new THREE.MeshBasicMaterial();
break;
case 'MeshPhongMaterial':
material = new THREE.MeshPhongMaterial();
break;
case 'MeshLambertMaterial':
material = new THREE.MeshLambertMaterial();
break;
default:
material = null;
break;
}

const boxx = new WHS.Box({
geometry: {
height: msg.mesh.geometry.height,
width: msg.mesh.geometry.width,
depth: msg.mesh.geometry.depth
},

shadow: msg.mesh.shadow,
position: msg.mesh.position,
material: new THREE.MeshBasicMaterial()
material
});

boxx.uuid = msg.uuid;
Expand Down Expand Up @@ -69,7 +86,8 @@ export default class SocketModule {
const mesh = {
geometry: this.geometry,
position: this.position,
material: this.material
material: this.material,
shadow: this.shadow
};

self.meshes.set(this.uuid, this);
Expand Down

0 comments on commit 82d27fe

Please sign in to comment.