bg2e-js 2.0.1 → 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.
- package/dist/bg2e-js.js +11001 -0
- package/dist/bg2e-js.js.map +1 -0
- package/package.json +17 -6
- package/app/AppController.d.ts +0 -37
- package/app/AppController.js +0 -32
- package/app/Canvas.d.ts +0 -42
- package/app/Canvas.js +0 -98
- package/app/EventBase.js +0 -8
- package/app/KeyboardEvent.js +0 -51
- package/app/MainLoop.d.ts +0 -245
- package/app/MainLoop.js +0 -251
- package/app/MouseEvent.js +0 -77
- package/app/TouchEvent.js +0 -15
- package/base/Color.js +0 -131
- package/base/Environment.js +0 -78
- package/base/Light.js +0 -176
- package/base/Material.js +0 -619
- package/base/PolyList.js +0 -336
- package/base/Texture.js +0 -545
- package/db/Bg2LoaderPlugin.js +0 -113
- package/db/DBPluginApi.js +0 -40
- package/db/Loader.js +0 -91
- package/db/LoaderPlugin.js +0 -26
- package/db/MtlParser.js +0 -7
- package/db/ObjLoaderPlugin.js +0 -51
- package/db/ObjParser.js +0 -233
- package/db/ObjWriterPlugin.js +0 -18
- package/db/VitscnjLoaderPlugin.js +0 -87
- package/db/Writer.js +0 -49
- package/db/WriterPlugin.js +0 -20
- package/debug/DebugRenderer.js +0 -138
- package/debug/WebGLTextureViewer.js +0 -67
- package/manipulation/SelectionBuffer.js +0 -65
- package/manipulation/SelectionHighlight.js +0 -69
- package/manipulation/SelectionIdAssignVisitor.js +0 -86
- package/manipulation/SelectionManager.js +0 -134
- package/manipulation/SelectionMode.js +0 -6
- package/math/Mat3.js +0 -248
- package/math/Mat4.js +0 -694
- package/math/MatrixStrategy.js +0 -23
- package/math/Quat.js +0 -60
- package/math/Vec.js +0 -728
- package/math/constants.js +0 -44
- package/math/functions.js +0 -104
- package/math/index.js +0 -74
- package/phsics/joint.js +0 -124
- package/primitives/arrow.js +0 -58
- package/primitives/cone.js +0 -137
- package/primitives/cube.js +0 -59
- package/primitives/cylinder.js +0 -215
- package/primitives/index.js +0 -13
- package/primitives/plane.js +0 -31
- package/primitives/sphere.js +0 -808
- package/render/BRDFIntegrationMap.js +0 -4
- package/render/Environment.js +0 -105
- package/render/EnvironmentRenderer.js +0 -12
- package/render/FrameBuffer.js +0 -26
- package/render/MaterialRenderer.js +0 -28
- package/render/Pipeline.js +0 -83
- package/render/PolyListRenderer.js +0 -42
- package/render/RenderBuffer.js +0 -189
- package/render/RenderQueue.js +0 -162
- package/render/RenderState.js +0 -82
- package/render/Renderer.js +0 -202
- package/render/SceneAppController.js +0 -208
- package/render/SceneRenderer.js +0 -310
- package/render/Shader.js +0 -21
- package/render/ShadowRenderer.js +0 -159
- package/render/SkyCube.js +0 -77
- package/render/SkySphere.js +0 -94
- package/render/TextureMergerRenderer.js +0 -58
- package/render/TextureRenderer.js +0 -29
- package/render/webgl/FrameBuffer.js +0 -9
- package/render/webgl/MaterialRenderer.js +0 -99
- package/render/webgl/Pipeline.js +0 -82
- package/render/webgl/PolyListRenderer.js +0 -224
- package/render/webgl/RenderBuffer.js +0 -244
- package/render/webgl/Renderer.js +0 -239
- package/render/webgl/SceneRenderer.js +0 -43
- package/render/webgl/ShaderProgram.js +0 -350
- package/render/webgl/ShadowRenderer.js +0 -6
- package/render/webgl/SkyCube.js +0 -15
- package/render/webgl/SkySphere.js +0 -14
- package/render/webgl/State.js +0 -149
- package/render/webgl/TextureRenderer.js +0 -167
- package/render/webgl/VertexBuffer.js +0 -128
- package/scene/Camera.js +0 -378
- package/scene/Chain.js +0 -43
- package/scene/ChainJoint.js +0 -55
- package/scene/Component.js +0 -146
- package/scene/ComponentMap.js +0 -99
- package/scene/Drawable.js +0 -130
- package/scene/EnvironmentComponent.js +0 -123
- package/scene/FindNodeVisitor.js +0 -55
- package/scene/LightComponent.js +0 -146
- package/scene/MatrixState.js +0 -39
- package/scene/Node.js +0 -300
- package/scene/NodeVisitor.js +0 -12
- package/scene/OrbitCameraController.js +0 -407
- package/scene/SmoothOrbitCameraController.js +0 -92
- package/scene/Transform.js +0 -74
- package/scene/index.js +0 -24
- package/shaders/BasicDiffuseColorShader.js +0 -91
- package/shaders/BasicPBRLightShader.js +0 -238
- package/shaders/DebugRenderShader.js +0 -79
- package/shaders/DepthRenderShader.js +0 -69
- package/shaders/IrradianceMapCubeShader.js +0 -99
- package/shaders/PBRLightIBLShader.js +0 -380
- package/shaders/PickSelectionShader.js +0 -75
- package/shaders/PresentDebugFramebufferShader.js +0 -90
- package/shaders/PresentTextureShader.js +0 -73
- package/shaders/SelectionHighlightShader.js +0 -98
- package/shaders/ShaderFunction.js +0 -72
- package/shaders/SkyCubeShader.js +0 -78
- package/shaders/SkySphereShader.js +0 -77
- package/shaders/SpecularMapCubeShader.js +0 -145
- package/shaders/TextureMergerShader.js +0 -127
- package/shaders/webgl_shader_lib.js +0 -187
- package/tools/BinaryResourceProvider.js +0 -15
- package/tools/ImageResourceProvider.js +0 -65
- package/tools/MaterialModifier.js +0 -228
- package/tools/Resource.js +0 -177
- package/tools/ResourceProvider.js +0 -56
- package/tools/TextResourceProvider.js +0 -24
- package/tools/TextureCache.js +0 -44
- package/tools/TextureResourceDatabase.js +0 -87
- package/tools/UserAgent.js +0 -294
- package/tools/VideoResourceProvider.js +0 -51
- package/tools/WriteStrategy.js +0 -22
- package/tools/base64.js +0 -15
- package/tools/crypto.js +0 -15
- package/tools/endiantess.js +0 -15
- package/tools/image.js +0 -15
- package/tools/index.js +0 -33
- package/tools/processType.js +0 -56
package/scene/MatrixState.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import Mat4 from "../math/Mat4";
|
|
3
|
-
|
|
4
|
-
const pushMatrix = function(mat,stack,id) {
|
|
5
|
-
stack.push(new Mat4(mat));
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const popMatrix = function(mat,stack,id) {
|
|
9
|
-
if (stack.length>0) {
|
|
10
|
-
mat.assign(stack[stack.length - 1]);
|
|
11
|
-
stack.splice(stack.length - 1, 1);
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
throw new Error(`Matrix stack underflow detected in ${id} matrix`)
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export default class MatrixState {
|
|
19
|
-
constructor() {
|
|
20
|
-
this._projection = Mat4.MakeIdentity();
|
|
21
|
-
this._view = Mat4.MakeIdentity();
|
|
22
|
-
this._model = Mat4.MakeIdentity();
|
|
23
|
-
|
|
24
|
-
this._projMatrixStack = [];
|
|
25
|
-
this._viewMatrixStack = [];
|
|
26
|
-
this._modelMatrixStack = [];
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
get projection() { return this._projection; }
|
|
30
|
-
get view() { return this._view; }
|
|
31
|
-
get model() { return this._model; }
|
|
32
|
-
|
|
33
|
-
pushProjection() { pushMatrix(this._projection, this._projMatrixStack, 'projection'); }
|
|
34
|
-
popProjection() { popMatrix(this._projection, this._projMatrixStack, 'projection'); }
|
|
35
|
-
pushView() { pushMatrix(this._view, this._viewMatrixStack, 'view'); }
|
|
36
|
-
popView() { popMatrix(this._view, this._viewMatrixStack, 'view'); }
|
|
37
|
-
pushModel() { pushMatrix(this._model, this._modelMatrixStack, 'model'); }
|
|
38
|
-
popModel() { popMatrix(this._model, this._modelMatrixStack, 'model'); }
|
|
39
|
-
}
|
package/scene/Node.js
DELETED
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
import Mat4 from '../math/Mat4';
|
|
2
|
-
import ComponentMap from './ComponentMap';
|
|
3
|
-
|
|
4
|
-
export function bindRenderer(node, renderer) {
|
|
5
|
-
node._bindedRenderer = renderer;
|
|
6
|
-
node.components.forEach(comp => {
|
|
7
|
-
comp.bindRenderer(renderer);
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export async function init(node) {
|
|
12
|
-
for (const i in node.components.array) {
|
|
13
|
-
const comp = node.components.array[i];
|
|
14
|
-
if (!comp._initialized) {
|
|
15
|
-
await comp.init();
|
|
16
|
-
comp._initialized = true;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
node._sceneChanged = false;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export default class Node {
|
|
23
|
-
constructor(name = "") {
|
|
24
|
-
this._name = name;
|
|
25
|
-
this._enabled = true;
|
|
26
|
-
this._steady = false;
|
|
27
|
-
|
|
28
|
-
this._components = new ComponentMap(this);
|
|
29
|
-
|
|
30
|
-
this._parent = null;
|
|
31
|
-
this._children = [];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
get name() { return this._name; }
|
|
35
|
-
set name(n) { this._name = n; }
|
|
36
|
-
|
|
37
|
-
get enabled() { return this._enabled; }
|
|
38
|
-
set enabled(e) { this._enabled = e; }
|
|
39
|
-
|
|
40
|
-
get steady() { return this._steady; }
|
|
41
|
-
set steady(s) { this._steady = s; }
|
|
42
|
-
|
|
43
|
-
get components() { return this._components; }
|
|
44
|
-
|
|
45
|
-
get parent() { return this._parent; }
|
|
46
|
-
get children() { return this._children; }
|
|
47
|
-
|
|
48
|
-
clone(cloneChildren=false) {
|
|
49
|
-
const newNode = new Node();
|
|
50
|
-
newNode.assign(this,cloneChildren);
|
|
51
|
-
return newNode;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
assign(other,cloneChildren=false) {
|
|
55
|
-
this._name = other.name + "-copy";
|
|
56
|
-
this._enabled = other.enabled;
|
|
57
|
-
this._steady = other.steady;
|
|
58
|
-
this._components.assign(other._components);
|
|
59
|
-
if (cloneChildren) {
|
|
60
|
-
this._children = [];
|
|
61
|
-
other._children.forEach(c => {
|
|
62
|
-
this._children.push(c.clone(cloneChildren));
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
destroy() {
|
|
68
|
-
this._components.empty();
|
|
69
|
-
this.emptyChildren();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
async deserialize(sceneData,loader) {
|
|
73
|
-
throw new Error("Node.deserialize() not implemented");
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
async serialize(sceneData,writer) {
|
|
77
|
-
throw new Error("Node.serialice() not implemented");
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
addComponent(component) {
|
|
81
|
-
this.components.add(component);
|
|
82
|
-
this.setSceneChanged();
|
|
83
|
-
return component;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
component(typeId) {
|
|
87
|
-
return this.components.find(typeId);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
removeComponent(component) {
|
|
91
|
-
this.components.remove(component);
|
|
92
|
-
this.setSceneChanged();
|
|
93
|
-
return component;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
addedToNode(node) {
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
removedFromNode(node) {
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// This attribute returns true if a node or component
|
|
105
|
-
// has been added or removed to this node or any child node
|
|
106
|
-
get sceneChanged() {
|
|
107
|
-
return this._sceneChanged;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
setSceneChanged() {
|
|
111
|
-
this._sceneChanged = true;
|
|
112
|
-
if (this._parent) {
|
|
113
|
-
this._parent.setSceneChanged();
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
addChild(node) {
|
|
118
|
-
if (node._parent) {
|
|
119
|
-
node._parent.removeChild(node);
|
|
120
|
-
}
|
|
121
|
-
node._parent = this;
|
|
122
|
-
this._children.push(node);
|
|
123
|
-
node.addedToNode(this);
|
|
124
|
-
|
|
125
|
-
// If this node has been binded to a renderer, we need to bind
|
|
126
|
-
// the same renderer to any node that is added as child
|
|
127
|
-
if (this._bindedRenderer) {
|
|
128
|
-
bindRenderer(node, this._bindedRenderer);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
this.setSceneChanged();
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
removeChild(node) {
|
|
135
|
-
if (node._parent === this) {
|
|
136
|
-
node._parent = null;
|
|
137
|
-
node.removedFromNode(this);
|
|
138
|
-
const index = this._children.indexOf(node);
|
|
139
|
-
if (index !== -1) {
|
|
140
|
-
this._children.splice(index, 1);
|
|
141
|
-
this.setSceneChanged();
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
console.warn(`Scene inconsistency found removing node '${ node.name }' from node '${ this.name }'. The parent node is valid, but the child is not present in the children array.`);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
throw new Error(`Node.removeChild() - the specified node is not a child of this node.`);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
emptyChildren() {
|
|
153
|
-
this._children.forEach(ch => {
|
|
154
|
-
ch._parent = null;
|
|
155
|
-
ch.removedFromNode(this);
|
|
156
|
-
});
|
|
157
|
-
this._children = [];
|
|
158
|
-
this.setSceneChanged();
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
haveChild(node) {
|
|
162
|
-
return this._children.indexOf(node) !== -1;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
isAncientOf(node) {
|
|
166
|
-
const isNodeAncient = (node, ancient) => {
|
|
167
|
-
if (!node || !ancient) {
|
|
168
|
-
return false;
|
|
169
|
-
}
|
|
170
|
-
else if (node._parent === ancient) {
|
|
171
|
-
return true;
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
return isNodeAncient(node._parent, ancient);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
isNodeAncient(this,node);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// Visitor functions
|
|
181
|
-
accept(nodeVisitor) {
|
|
182
|
-
if (!nodeVisitor.ignoreDisabled || this.enabled) {
|
|
183
|
-
nodeVisitor.visit(this);
|
|
184
|
-
this._children.forEach(ch => ch.accept(nodeVisitor));
|
|
185
|
-
nodeVisitor.didVisit(this);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
acceptReverse(nodeVisitor) {
|
|
190
|
-
if (!nodeVisitor.ignoreDisabled || this.enabled) {
|
|
191
|
-
if (this._parent) {
|
|
192
|
-
this._parent.acceptReverse(nodeVisitor);
|
|
193
|
-
}
|
|
194
|
-
nodeVisitor.visit(this);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
async asyncAccept(nodeVisitor) {
|
|
199
|
-
if (!nodeVisitor.ignoreDisabled || this.enabled) {
|
|
200
|
-
await nodeVisitor.asyncVisit(this);
|
|
201
|
-
for (const ch in this._children) {
|
|
202
|
-
await this._children[ch].asyncAccept(nodeVisitor);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// Most usual components
|
|
208
|
-
get transform() {
|
|
209
|
-
return this.component("Transform");
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
get lightComponent() {
|
|
213
|
-
return this.component("Light");
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
get drawable() {
|
|
217
|
-
return this.component("Drawable");
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
get camera() {
|
|
221
|
-
return this.component("Camera");
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
frame(delta, modelMatrix, renderQueue) {
|
|
225
|
-
const willUpdateComponents = [];
|
|
226
|
-
const updateComponents = [];
|
|
227
|
-
const drawComponents = [];
|
|
228
|
-
this._components.forEach(comp => {
|
|
229
|
-
if (comp.requireWillUpdate) {
|
|
230
|
-
willUpdateComponents.push(comp);
|
|
231
|
-
}
|
|
232
|
-
if (comp.requireUpdate) {
|
|
233
|
-
updateComponents.push(comp);
|
|
234
|
-
}
|
|
235
|
-
if (comp.requireDraw) {
|
|
236
|
-
drawComponents.push(comp);
|
|
237
|
-
}
|
|
238
|
-
})
|
|
239
|
-
|
|
240
|
-
willUpdateComponents.forEach(comp => comp.willUpdate(delta));
|
|
241
|
-
updateComponents.forEach(comp => comp.update(delta, modelMatrix));
|
|
242
|
-
drawComponents.forEach(comp => comp.draw(renderQueue, modelMatrix));
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
keyDown(evt) {
|
|
246
|
-
this._components.forEach(comp => {
|
|
247
|
-
comp.keyDown(evt);
|
|
248
|
-
})
|
|
249
|
-
}
|
|
250
|
-
keyUp(evt) {
|
|
251
|
-
this._components.forEach(comp => {
|
|
252
|
-
comp.keyUp(evt);
|
|
253
|
-
})
|
|
254
|
-
}
|
|
255
|
-
mouseUp(evt) {
|
|
256
|
-
this._components.forEach(comp => {
|
|
257
|
-
comp.mouseUp(evt);
|
|
258
|
-
})
|
|
259
|
-
}
|
|
260
|
-
mouseDown(evt) {
|
|
261
|
-
this._components.forEach(comp => {
|
|
262
|
-
comp.mouseDown(evt);
|
|
263
|
-
})
|
|
264
|
-
}
|
|
265
|
-
mouseMove(evt) {
|
|
266
|
-
this._components.forEach(comp => {
|
|
267
|
-
comp.mouseMove(evt);
|
|
268
|
-
})
|
|
269
|
-
}
|
|
270
|
-
mouseOut(evt) {
|
|
271
|
-
this._components.forEach(comp => {
|
|
272
|
-
comp.mouseOut(evt);
|
|
273
|
-
})
|
|
274
|
-
}
|
|
275
|
-
mouseDrag(evt) {
|
|
276
|
-
this._components.forEach(comp => {
|
|
277
|
-
comp.mouseDrag(evt);
|
|
278
|
-
})
|
|
279
|
-
}
|
|
280
|
-
mouseWheel(evt) {
|
|
281
|
-
this._components.forEach(comp => {
|
|
282
|
-
comp.mouseWheel(evt);
|
|
283
|
-
})
|
|
284
|
-
}
|
|
285
|
-
touchStart(evt) {
|
|
286
|
-
this._components.forEach(comp => {
|
|
287
|
-
comp.touchStart(evt);
|
|
288
|
-
})
|
|
289
|
-
}
|
|
290
|
-
touchMove(evt) {
|
|
291
|
-
this._components.forEach(comp => {
|
|
292
|
-
comp.touchMove(evt);
|
|
293
|
-
})
|
|
294
|
-
}
|
|
295
|
-
touchEnd(evt) {
|
|
296
|
-
this._components.forEach(comp => {
|
|
297
|
-
comp.touchEnd(evt);
|
|
298
|
-
})
|
|
299
|
-
}
|
|
300
|
-
}
|
package/scene/NodeVisitor.js
DELETED