bg2e-js 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/dist/bg2e-js.js +11001 -0
  2. package/dist/bg2e-js.js.map +1 -0
  3. package/package.json +17 -6
  4. package/app/AppController.js +0 -32
  5. package/app/Canvas.js +0 -98
  6. package/app/EventBase.js +0 -8
  7. package/app/KeyboardEvent.js +0 -51
  8. package/app/MainLoop.js +0 -251
  9. package/app/MouseEvent.js +0 -77
  10. package/app/TouchEvent.js +0 -15
  11. package/base/Color.js +0 -131
  12. package/base/Environment.js +0 -78
  13. package/base/Light.js +0 -176
  14. package/base/Material.js +0 -619
  15. package/base/PolyList.js +0 -336
  16. package/base/Texture.js +0 -545
  17. package/db/Bg2LoaderPlugin.js +0 -113
  18. package/db/DBPluginApi.js +0 -40
  19. package/db/Loader.js +0 -91
  20. package/db/LoaderPlugin.js +0 -26
  21. package/db/MtlParser.js +0 -7
  22. package/db/ObjLoaderPlugin.js +0 -51
  23. package/db/ObjParser.js +0 -233
  24. package/db/ObjWriterPlugin.js +0 -18
  25. package/db/VitscnjLoaderPlugin.js +0 -87
  26. package/db/Writer.js +0 -49
  27. package/db/WriterPlugin.js +0 -20
  28. package/debug/DebugRenderer.js +0 -138
  29. package/debug/WebGLTextureViewer.js +0 -67
  30. package/manipulation/SelectionBuffer.js +0 -65
  31. package/manipulation/SelectionHighlight.js +0 -69
  32. package/manipulation/SelectionIdAssignVisitor.js +0 -86
  33. package/manipulation/SelectionManager.js +0 -134
  34. package/manipulation/SelectionMode.js +0 -6
  35. package/math/Mat3.js +0 -248
  36. package/math/Mat4.js +0 -694
  37. package/math/MatrixStrategy.js +0 -23
  38. package/math/Quat.js +0 -60
  39. package/math/Vec.js +0 -728
  40. package/math/constants.js +0 -44
  41. package/math/functions.js +0 -104
  42. package/math/index.js +0 -74
  43. package/phsics/joint.js +0 -124
  44. package/primitives/arrow.js +0 -58
  45. package/primitives/cone.js +0 -137
  46. package/primitives/cube.js +0 -59
  47. package/primitives/cylinder.js +0 -215
  48. package/primitives/index.js +0 -13
  49. package/primitives/plane.js +0 -31
  50. package/primitives/sphere.js +0 -808
  51. package/render/BRDFIntegrationMap.js +0 -4
  52. package/render/Environment.js +0 -105
  53. package/render/EnvironmentRenderer.js +0 -12
  54. package/render/FrameBuffer.js +0 -26
  55. package/render/MaterialRenderer.js +0 -28
  56. package/render/Pipeline.js +0 -83
  57. package/render/PolyListRenderer.js +0 -42
  58. package/render/RenderBuffer.js +0 -189
  59. package/render/RenderQueue.js +0 -162
  60. package/render/RenderState.js +0 -82
  61. package/render/Renderer.js +0 -202
  62. package/render/SceneAppController.js +0 -208
  63. package/render/SceneRenderer.js +0 -310
  64. package/render/Shader.js +0 -21
  65. package/render/ShadowRenderer.js +0 -159
  66. package/render/SkyCube.js +0 -77
  67. package/render/SkySphere.js +0 -94
  68. package/render/TextureMergerRenderer.js +0 -58
  69. package/render/TextureRenderer.js +0 -29
  70. package/render/webgl/FrameBuffer.js +0 -9
  71. package/render/webgl/MaterialRenderer.js +0 -99
  72. package/render/webgl/Pipeline.js +0 -82
  73. package/render/webgl/PolyListRenderer.js +0 -224
  74. package/render/webgl/RenderBuffer.js +0 -244
  75. package/render/webgl/Renderer.js +0 -239
  76. package/render/webgl/SceneRenderer.js +0 -43
  77. package/render/webgl/ShaderProgram.js +0 -348
  78. package/render/webgl/ShadowRenderer.js +0 -6
  79. package/render/webgl/SkyCube.js +0 -15
  80. package/render/webgl/SkySphere.js +0 -14
  81. package/render/webgl/State.js +0 -149
  82. package/render/webgl/TextureRenderer.js +0 -167
  83. package/render/webgl/VertexBuffer.js +0 -128
  84. package/scene/Camera.js +0 -378
  85. package/scene/Chain.js +0 -43
  86. package/scene/ChainJoint.js +0 -55
  87. package/scene/Component.js +0 -146
  88. package/scene/ComponentMap.js +0 -99
  89. package/scene/Drawable.js +0 -130
  90. package/scene/EnvironmentComponent.js +0 -123
  91. package/scene/FindNodeVisitor.js +0 -55
  92. package/scene/LightComponent.js +0 -146
  93. package/scene/MatrixState.js +0 -39
  94. package/scene/Node.js +0 -300
  95. package/scene/NodeVisitor.js +0 -12
  96. package/scene/OrbitCameraController.js +0 -407
  97. package/scene/SmoothOrbitCameraController.js +0 -92
  98. package/scene/Transform.js +0 -74
  99. package/scene/index.js +0 -24
  100. package/shaders/BasicDiffuseColorShader.js +0 -91
  101. package/shaders/BasicPBRLightShader.js +0 -238
  102. package/shaders/DebugRenderShader.js +0 -79
  103. package/shaders/DepthRenderShader.js +0 -69
  104. package/shaders/IrradianceMapCubeShader.js +0 -99
  105. package/shaders/PBRLightIBLShader.js +0 -380
  106. package/shaders/PickSelectionShader.js +0 -75
  107. package/shaders/PresentDebugFramebufferShader.js +0 -90
  108. package/shaders/PresentTextureShader.js +0 -73
  109. package/shaders/SelectionHighlightShader.js +0 -98
  110. package/shaders/ShaderFunction.js +0 -72
  111. package/shaders/SkyCubeShader.js +0 -78
  112. package/shaders/SkySphereShader.js +0 -77
  113. package/shaders/SpecularMapCubeShader.js +0 -145
  114. package/shaders/TextureMergerShader.js +0 -127
  115. package/shaders/webgl_shader_lib.js +0 -187
  116. package/tools/BinaryResourceProvider.js +0 -15
  117. package/tools/ImageResourceProvider.js +0 -65
  118. package/tools/MaterialModifier.js +0 -228
  119. package/tools/Resource.js +0 -177
  120. package/tools/ResourceProvider.js +0 -56
  121. package/tools/TextResourceProvider.js +0 -24
  122. package/tools/TextureCache.js +0 -44
  123. package/tools/TextureResourceDatabase.js +0 -87
  124. package/tools/UserAgent.js +0 -294
  125. package/tools/VideoResourceProvider.js +0 -51
  126. package/tools/WriteStrategy.js +0 -22
  127. package/tools/base64.js +0 -15
  128. package/tools/crypto.js +0 -15
  129. package/tools/endiantess.js +0 -15
  130. package/tools/image.js +0 -15
  131. package/tools/index.js +0 -33
  132. package/tools/processType.js +0 -56
package/db/Loader.js DELETED
@@ -1,91 +0,0 @@
1
-
2
- import { isAbsolute, jointUrl, ResourceType } from '../tools/Resource';
3
- import {
4
- PluginOperationType,
5
- createPluginDatabase,
6
- registerPluginInDatabase,
7
- getPluginFromDatabase
8
- } from './DBPluginApi';
9
- import Canvas from '../app/Canvas';
10
-
11
- const g_loadPluginDatabase = createPluginDatabase(PluginOperationType.Read);
12
-
13
- export const registerLoaderPlugin = (pluginInstance) => {
14
- pluginInstance.dependencies.forEach(dep => registerPluginInDatabase(dep, g_loadPluginDatabase));
15
- registerPluginInDatabase(pluginInstance, g_loadPluginDatabase);
16
- }
17
-
18
- export const getLoaderPlugin = (path, type) => {
19
- return getPluginFromDatabase(path, type, g_loadPluginDatabase);
20
- }
21
-
22
- const getClearedCache = () => {
23
- return {
24
- PolyList: {},
25
- Drawable: {},
26
- Node: {},
27
- Texture: {},
28
- Material: {}
29
- }
30
- }
31
-
32
- export default class Loader {
33
- constructor(canvas) {
34
- this._canvas = canvas || Canvas.FirstCanvas();
35
- this._cache = getClearedCache();
36
- this._currentPath = "";
37
- }
38
-
39
- get canvas() {
40
- return this._canvas;
41
- }
42
-
43
- get currentPath() {
44
- return this._currentPath;
45
- }
46
-
47
- set currentPath(p) {
48
- this._currentPath = p;
49
- }
50
-
51
- clearCache() {
52
- this._cache = getClearedCache();
53
- }
54
-
55
- findCache(path,type) {
56
- return this._cache[type] && this._cache[type][path];
57
- }
58
-
59
- async loadResource(path,type) {
60
- if (!isAbsolute(path) && this.currentPath !== "") {
61
- path = jointUrl(this.currentPath, path);
62
- }
63
- let result = this.findCache(path, type);
64
- if (!result) {
65
- const plugin = getLoaderPlugin(path, type);
66
- result = await plugin.load(path, type, this);
67
- }
68
- return result;
69
- }
70
-
71
- async loadPolyList(path) {
72
- return await this.loadResource(path, ResourceType.PolyList);
73
- }
74
-
75
- async loadDrawable(path) {
76
- return await this.loadResource(path, ResourceType.Drawable);
77
- }
78
-
79
- async loadNode(path) {
80
- return await this.loadResource(path, ResourceType.Node);
81
- }
82
-
83
- async loadTexture(path) {
84
- return await this.loadResource(path, ResourceType.Texture);
85
- }
86
-
87
- async loadMaterial(path) {
88
- return await this.loadResource(path, ResourceType.Material);
89
- }
90
- }
91
-
@@ -1,26 +0,0 @@
1
-
2
-
3
- export default class LoaderPlugin {
4
- // Returns an array of valid file extensions for this plugin
5
- // example: ["obj","dae"]
6
- get supportedExtensions() {
7
- throw new Error("LoaderPlugin.supportedExtensions: attribute not implemented");
8
- }
9
-
10
- // Returns the resource types that the loader plugin can handle
11
- // example: [ ResourceType.PolyList, ResourceType.Scene ]
12
- get resourceTypes() {
13
- throw new Error("LoaderPlugin.resourceTypes: attribute not implemented");
14
- }
15
-
16
- // Returns the resource loaded with the path. The resource type must be one
17
- // of the specified in the resourceTypes attribute
18
- async load(path, type, loader) {
19
- throw new Error("LoaderPlugin.load(): method not implemented");
20
- }
21
-
22
- // Returns an array of LoaderPlugin objects that are necessary for this plugin to work.
23
- get dependencies() {
24
- return [];
25
- }
26
- }
package/db/MtlParser.js DELETED
@@ -1,7 +0,0 @@
1
-
2
-
3
- export default class MtlParser {
4
- constructor(mtlText) {
5
-
6
- }
7
- }
@@ -1,51 +0,0 @@
1
- import LoaderPlugin from './LoaderPlugin';
2
- import Resource, { getFileName, removeExtension, removeFileName, ResourceType } from './../tools/Resource';
3
- import ObjParser from './ObjParser';
4
- import Drawable from '../scene/Drawable';
5
- import Material from '../base/Material';
6
-
7
- const buildDrawable = (polyListArray,mtlData,filePath) => {
8
- const name = removeExtension(getFileName(filePath));
9
- const drawable = new Drawable(name);
10
-
11
- polyListArray.forEach(plist => {
12
- // TODO: set mtl data
13
- const mat = new Material();
14
- drawable.addPolyList(plist,mat);
15
- });
16
-
17
- return drawable;
18
- }
19
-
20
- export default class ObjLoaderPlugin extends LoaderPlugin {
21
- constructor() {
22
- super();
23
- this._resource = new Resource();
24
- }
25
-
26
- get supportedExtensions() { return ['obj']; }
27
-
28
- get resourceTypes() {
29
- return [
30
- ResourceType.PolyList,
31
- ResourceType.Drawable
32
- ];
33
- }
34
-
35
- async load(path,resourceType,loader) {
36
- const objText = await this._resource.load(path);
37
- const parser = new ObjParser(objText);
38
-
39
- // TODO: load material from mtl file
40
- // const relativePath = removeFileName(filePath);
41
-
42
- switch (resourceType) {
43
- case ResourceType.PolyList:
44
- return parser.polyListArray;
45
- case ResourceType.Drawable:
46
- return buildDrawable(parser.polyListArray, null, path);
47
- default:
48
- throw new Error(`ObjLoaderPlugin.load() unexpected resource type received: ${resourceType}`);
49
- }
50
- }
51
- }
package/db/ObjParser.js DELETED
@@ -1,233 +0,0 @@
1
-
2
- import PolyList from "../base/PolyList";
3
-
4
- function parseM(line) {
5
- // mtllib
6
- let res = /mtllib\s+(.*)/.exec(line);
7
- if (res) {
8
- this._mtlLib = res[1];
9
- }
10
- }
11
-
12
- function parseG(line) {
13
- // g
14
- let res = /g\s+(.*)/.exec(line);
15
- if (res) {
16
- this._currentPlist.name = res[1];
17
- }
18
- }
19
-
20
- function parseU(line) {
21
- // usemtl
22
- let res = /usemtl\s+(.*)/.exec(line);
23
- if (res) {
24
- this._currentPlist._matName = res[1];
25
- if (this._currentPlist.name=="") {
26
- this._currentPlist.name = res[1];
27
- }
28
- }
29
- }
30
-
31
- function parseS(line) {
32
- // s
33
- let res = /s\s+(.*)/.exec(line);
34
- if (res) {
35
- // TODO: Do something with smoothing groups
36
- }
37
- }
38
-
39
- function addPoint(pointData) {
40
- this._currentPlist.vertex.push(pointData.vertex[0],pointData.vertex[1],pointData.vertex[2]);
41
- if (pointData.normal) {
42
- this._currentPlist.normal.push(pointData.normal[0],pointData.normal[1],pointData.normal[2]);
43
- }
44
- if (pointData.tex) {
45
- this._currentPlist.texCoord0.push(pointData.tex[0],pointData.tex[1]);
46
- }
47
- this._currentPlist.index.push(this._currentPlist.index.length);
48
- }
49
-
50
- function isValid(point) {
51
- return point && point.vertex && point.tex && point.normal;
52
- }
53
-
54
- function addPolygon(polygonData) {
55
- let currentVertex = 0;
56
- let sides = polygonData.length;
57
- if (sides<3) return;
58
- while (currentVertex<sides) {
59
- let i0 = currentVertex;
60
- let i1 = currentVertex + 1;
61
- let i2 = currentVertex + 2;
62
- if (i2==sides) {
63
- i2 = 0;
64
- }
65
- else if (i1==sides) {
66
- i1 = 0;
67
- i2 = 2;
68
- }
69
-
70
- let p0 = polygonData[i0];
71
- let p1 = polygonData[i1];
72
- let p2 = polygonData[i2];
73
-
74
- if (isValid(p0) && isValid(p1) && isValid(p2)) {
75
- addPoint.apply(this,[p0]);
76
- addPoint.apply(this,[p1]);
77
- addPoint.apply(this,[p2]);
78
- }
79
- else {
80
- console.warn("Invalid point data found loading OBJ file");
81
- }
82
- currentVertex+=3;
83
- }
84
- }
85
-
86
- function parseF(line) {
87
- // f
88
- this._addPlist = true;
89
- let res = /f\s+(.*)/.exec(line);
90
- if (res) {
91
- let params = res[1];
92
- let vtnRE = /([\d\-]+)\/([\d\-]*)\/([\d\-]*)/g;
93
- if (params.indexOf('/')==-1) {
94
- let vRE = /([\d\-]+)/g;
95
- }
96
- let polygon = [];
97
- while ( (res=vtnRE.exec(params)) ) {
98
- let iV = Number(res[1]);
99
- let iN = res[3] ? Number(res[3]):null;
100
- let iT = res[2] ? Number(res[2]):null;
101
- iV = iV<0 ? this._vertexArray.length + iV : iV - 1;
102
- iN = iN<0 ? this._normalArray.length + iN : (iN===null ? null : iN - 1);
103
- iT = iT<0 ? this._texCoordArray.length + iT : (iT===null ? null : iT - 1)
104
-
105
- let v = this._vertexArray[iV];
106
- let n = iN!==null ? this._normalArray[iN] : null;
107
- let t = iT!==null ? this._texCoordArray[iT] : null;
108
- polygon.push({
109
- vertex:v,
110
- normal:n,
111
- tex:t
112
- });
113
- }
114
- addPolygon.apply(this,[polygon]);
115
- }
116
- }
117
-
118
- function parseO(line) {
119
- // o
120
- let res = /s\s+(.*)/.exec(line);
121
- if (res && this._currentPlist.name=="") {
122
- this._currentPlist.name = res[1];
123
- }
124
- }
125
-
126
- function checkAddPlist() {
127
- if (this._addPlist) {
128
- if (this._currentPlist) {
129
- this._plistArray.push(this._currentPlist);
130
- }
131
- this._currentPlist = new PolyList();
132
- this._addPlist = false;
133
- }
134
- }
135
-
136
- function loadObjData() {
137
- let lines = this._textData.split('\n');
138
- let multiLine = "";
139
- lines.forEach(line => {
140
- line = line.trim();
141
-
142
- // This section controls the break line character \
143
- // to concatenate this new line with the next one
144
- if (multiLine) {
145
- line = multiLine + line;
146
- }
147
- if (line[line.length - 1] === '\\') {
148
- line = line.substring(0,line.length - 1);
149
- multiLine += line;
150
- return;
151
- }
152
- else {
153
- multiLine = "";
154
- }
155
-
156
- // First optimization: parse the first character and string length
157
- if (line.length>1 && line[0] !== '#') {
158
- // Second optimization: parse by the first character
159
- switch (line[0]) {
160
- case 'v':
161
- let res = /v\s+([\d\.\-e]+)\s+([\d\.\-e]+)\s+([\d\.\-e]+)/.exec(line);
162
- if (res) {
163
- this._vertexArray.push(
164
- [ Number(res[1]), Number(res[2]), Number(res[3]) ]
165
- );
166
- }
167
- else if ( (res = /vn\s+([\d\.\-e]+)\s+([\d\.\-e]+)\s+([\d\.\-e]+)/.exec(line)) ) {
168
- this._normalArray.push(
169
- [ Number(res[1]), Number(res[2]), Number(res[3]) ]
170
- );
171
- }
172
- else if ( (res = /vt\s+([\d\.\-e]+)\s+([\d\.\-e]+)/.exec(line)) ) {
173
- this._texCoordArray.push(
174
- [ Number(res[1]), Number(res[2]) ]
175
- );
176
- }
177
- else {
178
- console.warn("Error parsing line " + line);
179
- }
180
- break;
181
- case 'm':
182
- checkAddPlist.apply(this);
183
- parseM.apply(this,[line]);
184
- break;
185
- case 'g':
186
- checkAddPlist.apply(this);
187
- parseG.apply(this,[line]);
188
- break;
189
- case 'u':
190
- checkAddPlist.apply(this);
191
- parseU.apply(this,[line]);
192
- break;
193
- case 's':
194
- parseS.apply(this,[line]);
195
- break;
196
- case 'f':
197
- parseF.apply(this,[line]);
198
- break;
199
- case 'o':
200
- checkAddPlist.apply(this);
201
- parseO.apply(this,[line]);
202
- break;
203
- }
204
- }
205
- });
206
-
207
- if (this._currentPlist && this._addPlist) {
208
- this._plistArray.push(this._currentPlist);
209
- }
210
- }
211
-
212
- export default class ObjParser {
213
- constructor(objText) {
214
- this._textData = objText;
215
-
216
- this._plistArray = [];
217
-
218
- this._vertexArray = [];
219
- this._normalArray = [];
220
- this._texCoordArray = [];
221
-
222
- this._mtlLib = "";
223
-
224
- this._addPlist = true;
225
-
226
- loadObjData.apply(this);
227
- }
228
-
229
-
230
- get polyListArray() {
231
- return this._plistArray;
232
- }
233
- }
@@ -1,18 +0,0 @@
1
- import { ResourceType } from "../tools/Resource";
2
- import WriterPlugin from "./WriterPlugin";
3
-
4
- export default class ObjWriterPlugin extends WriterPlugin {
5
- get supportedExtensions() {
6
- return ["obj"];
7
- }
8
-
9
- get resourceTypes() {
10
- return ResourceType.Drawable;
11
- }
12
-
13
- async write(path, data, type) {
14
- console.log(path);
15
- console.log(data);
16
- console.log(type);
17
- }
18
- }
@@ -1,87 +0,0 @@
1
- import Resource, { removeFileName, ResourceType } from "../tools/Resource";
2
- import LoaderPlugin from "./LoaderPlugin";
3
- import Node from "../scene/Node";
4
- import { deserializeComponent } from "../scene/Component";
5
- import Bg2LoaderPlugin from "./Bg2LoaderPlugin";
6
-
7
- const deserializeNode = async (nodeData, loader) => {
8
- nodeData.children = nodeData.children || [];
9
- nodeData.components = nodeData.components || [];
10
-
11
- const node = new Node(nodeData.name);
12
- node.enabled = nodeData.enabled !== undefined ? nodeData.enabled : true;
13
- node.steady = nodeData.steady !== undefined ? nodeData.steady : false;
14
-
15
- for (const componentData of nodeData.components) {
16
- try {
17
- const component = await deserializeComponent(componentData, loader);
18
- if (component) {
19
- node.addComponent(component);
20
- }
21
- }
22
- catch (err) {
23
- console.warn(`Deserialization of node with name "${node.name}": ${err.message}`);
24
- }
25
- }
26
-
27
- for (const childData of nodeData.children) {
28
- const child = await deserializeNode(childData, loader);
29
- node.addChild(child);
30
- }
31
-
32
- return node;
33
- }
34
-
35
- export const DrawableFormat = {
36
- LEGACY: 'vwglb',
37
- BG2: 'bg2'
38
- };
39
-
40
- let g_prefDrawableFormat = DrawableFormat.BG2;
41
- export default class VitscnjLoaderPlugin extends LoaderPlugin {
42
- static PreferredDrawableFormat() {
43
- return g_prefDrawableFormat;
44
- }
45
-
46
- constructor({ bg2ioPath = null, preferedDrawableFormat = DrawableFormat.BG2 }) {
47
- super();
48
-
49
- this._bg2ioPath = bg2ioPath;
50
- g_prefDrawableFormat = preferedDrawableFormat;
51
- }
52
-
53
- get supportedExtensions() { return ["vitscnj"]; }
54
-
55
- get resourceTypes() {
56
- return [
57
- ResourceType.Node
58
- ];
59
- }
60
-
61
- async load(path,resourceType,loader) {
62
- if (resourceType !== ResourceType.Node) {
63
- throw new Error(`VitscnjLoaderPlugin.load() unexpected resource type received: ${resourceType}`);
64
- }
65
-
66
- const prevPath = loader.currentPath;
67
- loader.currentPath = removeFileName(path);
68
-
69
- const resource = new Resource();
70
-
71
- const root = new Node("Scene Root");
72
-
73
- const { scene } = await resource.load(path);
74
- for (const nodeData of scene) {
75
- const node = await deserializeNode(nodeData, loader);
76
- root.addChild(node);
77
- }
78
-
79
- loader.currentPath = prevPath;
80
-
81
- return root;
82
- }
83
-
84
- get dependencies() {
85
- return [new Bg2LoaderPlugin({ bg2ioPath: this._bg2ioPath })];
86
- }
87
- }
package/db/Writer.js DELETED
@@ -1,49 +0,0 @@
1
- import { ResourceType } from '../tools/Resource';
2
- import {
3
- PluginOperationType,
4
- createPluginDatabase,
5
- registerPluginInDatabase,
6
- getPluginFromDatabase
7
- } from './DBPluginApi';
8
-
9
- const g_writePluginDatabase = createPluginDatabase(PluginOperationType.Write);
10
-
11
- export const registerWriterPlugin = (pluginInstance) => {
12
- registerPluginInDatabase(pluginInstance, g_writePluginDatabase);
13
- }
14
-
15
- export const getWriterPlugin = (path, type) => {
16
- return getPluginFromDatabase(path, type, g_writePluginDatabase);
17
- }
18
-
19
- export default class Writer {
20
- constructor() {
21
-
22
- }
23
-
24
- async writeResource(path, data, type) {
25
- const plugin = getWriterPlugin(path, type);
26
- const result = await plugin.write(path, data, type, this);
27
- return result;
28
- }
29
-
30
- async writePolyList(path, data) {
31
- return await this.writeResource(path, data, ResourceType.PolyList);
32
- }
33
-
34
- async writeDrawable(path, data) {
35
- return await this.writeResource(path, data, ResourceType.Drawable);
36
- }
37
-
38
- async writeNode(path, data) {
39
- return await this.writeResource(path, data, ResourceType.Node);
40
- }
41
-
42
- async writeTexture(path, data) {
43
- return await this.writeResource(path, data, ResourceType.Texture);
44
- }
45
-
46
- async writeMaterial(path, data) {
47
- return await this.writeResource(path, data, ResourceType.Material);
48
- }
49
- }
@@ -1,20 +0,0 @@
1
-
2
- export default class WriterPlugin {
3
- // Returns an array of valid file extensions for this plugin
4
- // example: ['obj','dae']
5
- get supportedExtensions() {
6
- throw new Error("WriterPlugin.supportedExtensions: attribute not implemented");
7
- }
8
-
9
- // Returns the resource types that the loader plugin can handle
10
- // example: [ResourceType.PolyList, ResourceType.Drawable]
11
- get resourceTypes() {
12
- throw new Error("WriterPlugin.resourceTypes: attribute not implemented");
13
- }
14
-
15
- // Performs the write action to the specified path, using the specified data
16
- // and for the specified type.
17
- async write(path, data, type) {
18
- throw new Error("WriterPlugin.write(): method not implemented");
19
- }
20
- }