Repository navigation
Expand file tree
/
Copy pathtype.js
More file actions
56 lines (49 loc) · 2.27 KB
/
Copy pathtype.js
File metadata and controls
56 lines (49 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"use strict";
{
const SDK = self.SDK;
const PLUGIN_CLASS = SDK.Plugins.Mikal_3DObject;
PLUGIN_CLASS.Type = class Object3DType extends SDK.ITypeBase
{
constructor(sdkPlugin, iObjectType)
{
super(sdkPlugin, iObjectType);
this._project = iObjectType.GetProject();
this.initOwner = -1;
this.loaded = false;
this.gltfData = new globalThis.GltfData(this._project, this);
this.texture = {};
this.dataLoaded = false;
}
async LoadDynamicTextures(renderer, gltfData, textures, whiteTextureOwner, instanceModel)
{
if (gltfData.dynamicTexturesLoaded === true || gltfData.dynamicTexturesLoaded === null) return;
// White texture for solid color
const width = gltfData.whiteImageBitmap.width;
const height = gltfData.whiteImageBitmap.height;
whiteTextureOwner.whiteTexture = renderer.CreateDynamicTexture(width, height);
await renderer.UpdateTexture(gltfData.whiteImageBitmap, whiteTextureOwner.whiteTexture);
gltfData.whiteImageBitmap.close();
if (!gltfData.imageBitmap) {
gltfData.dynamicTexturesLoaded = true;
return;
}
gltfData.dynamicTexturesLoaded = null;
gltfData.dynamicTexturesLoaded = null;
for (const imageName in gltfData.imageBitmap) {
const width = gltfData.imageBitmap[imageName].width;
const height = gltfData.imageBitmap[imageName].height;
let options = {
wrapX: gltfData.imageBitmap[imageName].wrapS,
wrapY: gltfData.imageBitmap[imageName].wrapT,
};
textures[imageName] = renderer.CreateDynamicTexture(width, height, options);
await renderer.UpdateTexture(gltfData.imageBitmap[imageName], textures[imageName]);
if (typeof gltfData.imageBitmap[imageName].close === "function") gltfData.imageBitmap[imageName].close();
}
gltfData.dynamicTexturesLoaded = true;
if (instanceModel) {
// gltfData = null
}
}
};
}