MikaFil commited on
Commit
61ccdd8
·
verified ·
1 Parent(s): 3ba17c0

Update viewer.js

Browse files
Files changed (1) hide show
  1. viewer.js +21 -19
viewer.js CHANGED
@@ -1,6 +1,25 @@
1
  // viewer.js
2
  // ==============================
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  // --- Patch all window.Image to force crossOrigin="anonymous" ---
5
  (function() {
6
  const OriginalImage = window.Image;
@@ -44,24 +63,6 @@ function traverse(entity, callback) {
44
  }
45
  }
46
 
47
- async function loadImageAsTexture(url, app) {
48
- return new Promise((resolve, reject) => {
49
- const img = new window.Image();
50
- img.crossOrigin = "anonymous";
51
- img.onload = function() {
52
- const tex = new pc.Texture(app.graphicsDevice, {
53
- width: img.width,
54
- height: img.height,
55
- format: pc.PIXELFORMAT_R8_G8_B8_A8,
56
- });
57
- tex.setSource(img);
58
- resolve(tex);
59
- };
60
- img.onerror = reject;
61
- img.src = url;
62
- });
63
- }
64
-
65
  let pc;
66
  export let app = null;
67
  let cameraEntity = null;
@@ -231,7 +232,8 @@ export async function initializeViewer(config, instanceId) {
231
  app.root.addChild(presentoirEntity);
232
 
233
  if(!espace_expo_bool){
234
- const grilleTex = await loadImageAsTexture('https://huggingface.co/datasets/MikaFil/3D_models/resolve/main/EARCARE/textures/emit_map_1k.png', app);
 
235
  let matSol = new pc.StandardMaterial();
236
  matSol.blendType = pc.BLEND_NONE;
237
  matSol.emissive = new pc.Color(color_bg);
 
1
  // viewer.js
2
  // ==============================
3
 
4
+ async function loadImageAsTexture(url, app) {
5
+ return new Promise((resolve, reject) => {
6
+ const img = new window.Image();
7
+ img.crossOrigin = "anonymous";
8
+ img.onload = function() {
9
+ const tex = new pc.Texture(app.graphicsDevice, {
10
+ width: img.width,
11
+ height: img.height,
12
+ format: pc.PIXELFORMAT_R8_G8_B8_A8,
13
+ });
14
+ tex.setSource(img);
15
+ resolve(tex);
16
+ };
17
+ img.onerror = reject;
18
+ img.src = url;
19
+ });
20
+ }
21
+
22
+
23
  // --- Patch all window.Image to force crossOrigin="anonymous" ---
24
  (function() {
25
  const OriginalImage = window.Image;
 
63
  }
64
  }
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  let pc;
67
  export let app = null;
68
  let cameraEntity = null;
 
232
  app.root.addChild(presentoirEntity);
233
 
234
  if(!espace_expo_bool){
235
+ //const grilleTex = await loadImageAsTexture('https://huggingface.co/datasets/MikaFil/3D_models/resolve/main/EARCARE/textures/emit_map_1k.png', app);
236
+ const emitTex = await loadImageAsTexture('https://huggingface.co/datasets/MikaFil/3D_models/resolve/main/EARCARE/textures/emit_map_1k.png', app);
237
  let matSol = new pc.StandardMaterial();
238
  matSol.blendType = pc.BLEND_NONE;
239
  matSol.emissive = new pc.Color(color_bg);