MikaFil commited on
Commit
f97559f
·
verified ·
1 Parent(s): d044f9a

Update viewer.js

Browse files
Files changed (1) hide show
  1. viewer.js +31 -11
viewer.js CHANGED
@@ -12,7 +12,7 @@ let resizeObserver = null;
12
 
13
  // These will hold references to the material(s) you want to update.
14
  let matTransparent = null;
15
- //let matTransparent = null;
16
  let tubeEmit = null;
17
 
18
 
@@ -210,31 +210,51 @@ export async function initializeViewer(config, instanceId) {
210
 
211
 
212
  //the 2 materials for the main model :
213
- matTransparent = new pc.StandardMaterial();
214
  const ao = assets.ao_map.resource;
215
  const op = assets.op_map.resource;
216
  const thickness = assets.thickness_map.resource;
 
 
 
217
  matTransparent.blendType = pc.BLEND_NORMAL;
218
  matTransparent.diffuse = new pc.Color(0.7, 0.05, 0.05);
219
  matTransparent.specular = new pc.Color(0.01, 0.01, 0.01);
220
  matTransparent.shininess = 90;
221
  matTransparent.gloss = 1;
222
  matTransparent.metalness = 0.0;
223
- //matTransparent.useMetalness = true;
224
- //matTransparent.useDynamicRefraction = true;
225
- //matTransparent.refraction= 0.8;
226
- //matTransparent.refractionIndex = 1;
227
- //matTransparent.thickness = 30;
228
- //matTransparent.thicknessMap = thickness;
229
  matTransparent.opacityMap = op;
230
  matTransparent.opacityMapChannel = "r";
231
- matTransparent.opacity = 1;
232
  matTransparent.emissive = new pc.Color(0.372, 0.03, 0.003);
233
  matTransparent.emissiveMap = ao;
234
- matTransparent.emissiveIntensity = 3;
235
  matTransparent.update();
236
 
237
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238
 
239
  //material for the tube
240
  tubeEmit = new pc.StandardMaterial();
@@ -247,7 +267,7 @@ export async function initializeViewer(config, instanceId) {
247
  traverse(modelEntity, node => {
248
  if (node.render && node.render.meshInstances) {
249
  for (let mi of node.render.meshInstances) {
250
- mi.material = matTransparent;
251
  }
252
  }
253
  });
 
12
 
13
  // These will hold references to the material(s) you want to update.
14
  let matTransparent = null;
15
+ let matOpaque = null;
16
  let tubeEmit = null;
17
 
18
 
 
210
 
211
 
212
  //the 2 materials for the main model :
 
213
  const ao = assets.ao_map.resource;
214
  const op = assets.op_map.resource;
215
  const thickness = assets.thickness_map.resource;
216
+
217
+ //mat transparent
218
+ matTransparent = new pc.StandardMaterial();
219
  matTransparent.blendType = pc.BLEND_NORMAL;
220
  matTransparent.diffuse = new pc.Color(0.7, 0.05, 0.05);
221
  matTransparent.specular = new pc.Color(0.01, 0.01, 0.01);
222
  matTransparent.shininess = 90;
223
  matTransparent.gloss = 1;
224
  matTransparent.metalness = 0.0;
225
+ matTransparent.useMetalness = true;
226
+ matTransparent.useDynamicRefraction = true;
227
+ matTransparent.refraction= 0.8;
228
+ matTransparent.refractionIndex = 1;
229
+ matTransparent.thickness = 30;
230
+ matTransparent.thicknessMap = thickness;
231
  matTransparent.opacityMap = op;
232
  matTransparent.opacityMapChannel = "r";
233
+ matTransparent.opacity = 0.9;
234
  matTransparent.emissive = new pc.Color(0.372, 0.03, 0.003);
235
  matTransparent.emissiveMap = ao;
236
+ matTransparent.emissiveIntensity = 0.1;
237
  matTransparent.update();
238
 
239
 
240
+ //mat opaque
241
+ matOpaque = new pc.StandardMaterial();
242
+ matOpaque.blendType = pc.BLEND_NORMAL;
243
+ matOpaque.diffuse = new pc.Color(0.7, 0.05, 0.05);
244
+ matOpaque.specular = new pc.Color(0.01, 0.01, 0.01);
245
+ matOpaque.shininess = 90;
246
+ matOpaque.gloss = 1;
247
+ matOpaque.metalness = 0.0;
248
+ matOpaque.opacityMap = op;
249
+ matOpaque.opacityMapChannel = "r";
250
+ matOpaque.opacity = 1;
251
+ matOpaque.emissive = new pc.Color(0.372, 0.03, 0.003);
252
+ matOpaque.emissiveMap = ao;
253
+ matOpaque.emissiveIntensity = 3;
254
+ matOpaque.update();
255
+
256
+
257
+
258
 
259
  //material for the tube
260
  tubeEmit = new pc.StandardMaterial();
 
267
  traverse(modelEntity, node => {
268
  if (node.render && node.render.meshInstances) {
269
  for (let mi of node.render.meshInstances) {
270
+ mi.material = matOpaque;
271
  }
272
  }
273
  });