MikaFil commited on
Commit
2422f49
·
verified ·
1 Parent(s): 3c7eddf

Update viewer.js

Browse files
Files changed (1) hide show
  1. viewer.js +37 -0
viewer.js CHANGED
@@ -154,6 +154,43 @@ export async function initializeViewer(config, instanceId) {
154
  if (assets.glb && assets.glb.resource && assets.glb.resource.instantiateRenderEntity) {
155
  const glbEntity = assets.glb.resource.instantiateRenderEntity();
156
  app.root.addChild(glbEntity);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  }
158
 
159
  cameraEntity = new pc.Entity('camera');
 
154
  if (assets.glb && assets.glb.resource && assets.glb.resource.instantiateRenderEntity) {
155
  const glbEntity = assets.glb.resource.instantiateRenderEntity();
156
  app.root.addChild(glbEntity);
157
+
158
+ // set material :
159
+ matTransparent = new pc.StandardMaterial();
160
+ matTransparent.blendType = pc.BLEND_NORMAL;
161
+ matTransparent.diffuse = new pc.Color(0.7, 0.05, 0.05);
162
+ matTransparent.specular = new pc.Color(0.01, 0.01, 0.01);
163
+ matTransparent.gloss = 1;
164
+ matTransparent.metalness = 0;
165
+ matTransparent.useMetalness = true;
166
+ matTransparent.useDynamicRefraction = true;
167
+ matTransparent.depthWrite = true;
168
+ matTransparent.refraction= 0.8;
169
+ matTransparent.refractionIndex = 1;
170
+ matTransparent.thickness = 0.02;
171
+ matTransparent.thicknessMap = thickness;
172
+ matTransparent.opacityMap = op;
173
+ matTransparent.opacityMapChannel = "r";
174
+ matTransparent.opacity = 0.97;
175
+ matTransparent.emissive = new pc.Color(0.372, 0.03, 0.003);
176
+ matTransparent.emissiveMap = ao;
177
+ matTransparent.emissiveIntensity = 0.1;
178
+ matTransparent.update();
179
+
180
+ function traverse(entity, callback) {
181
+ callback(entity);
182
+ if (entity.children) {
183
+ entity.children.forEach(child => traverse(child, callback));
184
+ }
185
+ }
186
+
187
+ traverse(glbEntity, node => {
188
+ if (node.render && node.render.meshInstances) {
189
+ for (let mi of node.render.meshInstances) {
190
+ mi.material = matOpaque;
191
+ }
192
+ }
193
+ });
194
  }
195
 
196
  cameraEntity = new pc.Entity('camera');