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
@@ -1,78 +0,0 @@
1
-
2
-
3
- export default class Environment {
4
- constructor() {
5
- this._renderer = null;
6
-
7
- this._equirectangularTexture = null;
8
- this._irradianceIntensity = 1;
9
- this._showSkybox = true;
10
- this._cubemapSize = 512;
11
- this._irradianceMapSize = 32;
12
- this._specularMapSize = 32;
13
- this._specularMapL2Size = 32;
14
-
15
- this._dirty = true;
16
- }
17
-
18
- get equirectangularTexture() { return this._equirectangularTexture; }
19
- set equirectangularTexture(t) { this._equirectangularTexture = t; this._dirty = true; }
20
- get irradianceIntensity() { return this._irradianceIntensity; }
21
- set irradianceIntensity(value) { this._irradianceIntensity = value; this._dirty = true}
22
- get showSkybox() { return this._showSkybox; }
23
- set showSkybox(value) { this._showSkybox = value; this._dirty = true}
24
- get cubemapSize() { return this._cubemapSize; }
25
- set cubemapSize(value) { this._cubemapSize = value; this._dirty = true}
26
- get irradianceMapSize() { return this._irradianceMapSize; }
27
- set irradianceMapSize(value) { this._irradianceMapSize = value; this._dirty = true}
28
- get specularMapSize() { return this._specularMapSize; }
29
- set specularMapSize(value) { this._specularMapSize = value; this._dirty = true}
30
- get specularMapL2Size() { return this._specularMapL2Size; }
31
- set specularMapL2Size(value) { this._specularMapL2Size = value; this._dirty = true}
32
-
33
- get renderer() {
34
- return this._renderer;
35
- }
36
-
37
- destroy() {
38
- if (this.renderer) {
39
- this.renderer.destroy();
40
- }
41
- }
42
-
43
- clone() {
44
- const result = new SkyCube();
45
- result.assign(this);
46
- return result;
47
- }
48
-
49
- assign(other) {
50
- this.equirectangularTexture = other.equirectangularTexture;
51
- this.irradianceIntensity = other.irradianceIntensity;
52
- this.showSkybox = other.showSkybox;
53
- this.cubemapSize = other.cubemapSize;
54
- this.irradianceMapSize = other.irradianceMapSize;
55
- this.specularMapSize = other.specularMapSize;
56
- this.specularMapL2Size = other.specularMapL2Size;
57
- }
58
-
59
- async deserialize(sceneData) {
60
- this.equirectangularTexture = sceneData.equirectangularTexture || this.equirectangularTexture;
61
- this.irradianceIntensity = sceneData.irradianceIntensity || this.irradianceIntensity;
62
- this.showSkybox = sceneData.showSkybox || this.showSkybox;
63
- this.cubemapSize = sceneData.cubemapSize || this.cubemapSize;
64
- this.irradianceMapSize = sceneData.irradianceMapSize || this.irradianceMapSize;
65
- this.specularMapSize = sceneData.specularMapSize || this.specularMapSize;
66
- this.specularMapL2Size = sceneData.specularMapL2Size || this.specularMapL2Size;
67
- }
68
-
69
- async serialize(sceneData) {
70
- sceneData.equirectangularTexture = this.equirectangularTexture;
71
- sceneData.irradianceIntensity = this.irradianceIntensity;
72
- sceneData.showSkybox = this.showSkybox;
73
- sceneData.cubemapSize = this.cubemapSize;
74
- sceneData.irradianceMapSize = this.irradianceMapSize;
75
- sceneData.specularMapSize = this.specularMapSize;
76
- sceneData.specularMapL2Size = this.specularMapL2Size;
77
- }
78
- }
package/base/Light.js DELETED
@@ -1,176 +0,0 @@
1
-
2
- import Vec from '../math/Vec';
3
- import Mat4 from '../math/Mat4';
4
- import Color from './Color';
5
-
6
- export const LightType = Object.freeze({
7
- DIRECTIONAL: 4,
8
- SPOT: 1,
9
- POINT: 5,
10
- DISABLED: 10
11
- });
12
-
13
- export default class Light {
14
- constructor() {
15
- this._enabled = true;
16
-
17
- this._type = LightType.DIRECTIONAL;
18
-
19
- this._direction = new Vec(0,0,-1);
20
- this._position = new Vec(0,0,0);
21
-
22
- this._color = new Color({ rgb: 0.9 });
23
- this._intensity = 20;
24
- this._spotCutoff = 20;
25
- this._spotExponent = 30;
26
- this._shadowStrength = 0.7;
27
- this._castShadows = true;
28
- this._shadowBias = 0.00002;
29
-
30
- this._projection = Mat4.MakeOrtho(-10,10,-10,10,0.1,500.0);
31
-
32
- // Internal engine use. This attribute will not be serialized
33
- this._depthTexture = null;
34
- }
35
-
36
- clone() {
37
- const newLight = new Light();
38
- newLight.assign(this);
39
- return newLight;
40
- }
41
-
42
- assign(other) {
43
- this.enabled = other.enabled;
44
- this.type = other.type;
45
- this.direction.assign(other.direction);
46
- this.position.assign(other.position);
47
- this.color.assign(other.color);
48
- this.spotCutoff = other.spotCutoff;
49
- this.spotExponent = other.spotExponent;
50
- this.shadowStrength = other.shadowStrength;
51
- this.castShadows = other.castShadows;
52
- this.shadowBias = other.shadowBias;
53
- this.intensity = other.intensity;
54
- this.projection.assign(other.projection);
55
- }
56
-
57
- get enabled() { return this._enabled; }
58
- set enabled(v) { this._enabled = v; }
59
-
60
- get type() { return this._type; }
61
- set type(t) { this._type = t; }
62
-
63
- get direction() { return this._direction; }
64
- set direction(d) { this._direction = d; }
65
-
66
- get position() { return this._position; }
67
- set position(p) { this._position = p; }
68
-
69
- get color() { return this._color; }
70
- set color(c) {
71
- if (c.length === 3) {
72
- this._color = new Vec([c[0], c[1], c[2], 1]);
73
- }
74
- else if (c.length === 4) {
75
- this._color = new Vec(c);
76
- }
77
- else {
78
- throw new Error(`Invalid light color assignment. Parameter must be a three or four component array.`);
79
- }
80
- }
81
- get intensity() { return this._intensity; }
82
- set intensity(i) { this._intensity = i; }
83
-
84
- get spotCutoff() { return this._spotCutoff; }
85
- set spotCutoff(c) { this._spotCutoff = c; }
86
- get spotExponent() { return this._spotExponent; }
87
- set spotExponent(e) { this._spotExponent = e; }
88
-
89
- get shadowStrength() { return this._shadowStrength; }
90
- set shadowStrength(s) { this._shadowStrength = s; }
91
- get castShadows() { return this._castShadows; }
92
- set castShadows(s) { this._castShadows = s; }
93
- get shadowBias() { return this._shadowBias; }
94
- set shadowBias(s) { this._shadowBias = s; }
95
-
96
- get projection() { return this._projection; }
97
- set projection(p) { this._projection = p; }
98
-
99
- get depthTexture() {
100
- return this._depthTexture;
101
- }
102
-
103
- set depthTexture(t) {
104
- this._depthTexture = t;
105
- }
106
-
107
- get viewMatrix() {
108
- return this._viewMatrix;
109
- }
110
-
111
- set viewMatrix(m) {
112
- this._viewMatrix = m;
113
- }
114
-
115
- async deserialize(sceneData) {
116
- switch (sceneData.lightType) {
117
- case 'kTypeDirectional':
118
- case LightType.DIRECTIONAL:
119
- this._type = LightType.DIRECTIONAL;
120
- // Use the predefined shadow bias for directional lights
121
- //this._shadowBias = sceneData.shadowBias;
122
- break;
123
- case 'kTypeSpot':
124
- case LightType.SPOT:
125
- this._type = LightType.SPOT;
126
- this._shadowBias = sceneData.shadowBias;
127
- break;
128
- case 'kTypePoint':
129
- case LightType.POINT:
130
- this._type = LightType.POINT;
131
- break;
132
- default:
133
- this._type = LightType.DIRECTIONAL;
134
- }
135
-
136
- const defaultIntensity = () => this._type === LightType.DIRECTIONAL ? 1 : 20;
137
-
138
- this._position = sceneData.position || new Vec(0,0,0);
139
- this._direction = sceneData.direction || new Vec(0, 0, -1);
140
-
141
- if (sceneData.diffuse) {
142
- this._color = new Color(sceneData.diffuse);
143
- this._intensity = (sceneData.intensity || 1) * defaultIntensity();
144
- }
145
- else if (sceneData.color) {
146
- this._color = new Color(sceneData.color);
147
- this._intensity = sceneData.intensity || defaultIntensity();
148
- }
149
-
150
- this._spotCutoff = sceneData.spotCutoff || 20;
151
- this._spotExponent = sceneData.spotExponent || 30;
152
- this._shadowStrength = sceneData.shadowStrength || 1;
153
- if (sceneData.projection) {
154
- this._projection = new Mat4(sceneData.projection);
155
- }
156
- this._castShadows = sceneData.castShadows !== undefined ? sceneData.castShadows : true;
157
- }
158
-
159
- async serialize(sceneData) {
160
- const lightTypes = [];
161
- lightTypes[LightType.DIRECTIONAL] = "kTypeDirectional";
162
- lightTypes[LightType.SPOT] = "kTypeSpot";
163
- lightTypes[LightType.POINT] = "kTypePoint";
164
- sceneData.lightType = lightTypes[this._type];
165
- sceneData.position = this._position;
166
- sceneData.direction = this._direction;
167
- sceneData.color = this._color;
168
- sceneData.intensity = this._intensity;
169
- sceneData.spotCutoff = this._spotCutoff || 20;
170
- sceneData.spotExponent = this._spotExponent || 30;
171
- sceneData.shadowStrength = this._shadowStrength;
172
- sceneData.projection = this._projection;
173
- sceneData.castShadows = this._castShadows;
174
- sceneData.shadowBias = this._shadowBias || 0.0029;
175
- }
176
- }