ohzi-core 6.2.3 → 6.3.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/build/index.module.js +1 -1
- package/build/index.module.js.map +1 -1
- package/package.json +1 -1
- package/src/CustomBezierCurve.js +2 -2
- package/src/Debug.js +28 -28
- package/src/EventManager.js +1 -1
- package/src/Graphics.js +12 -12
- package/src/KeyboardInput.js +1 -1
- package/src/OS.js +5 -5
- package/src/UI.js +1 -1
- package/src/action_sequencer/ActionSequencer.js +17 -12
- package/src/action_sequencer/VectorInterpolator.js +1 -1
- package/src/canvas_drawer/CanvasDrawer.js +8 -8
- package/src/canvas_drawer/MultiLineTextDrawer.js +3 -3
- package/src/canvas_drawer/SimpleTextDrawer.js +1 -1
- package/src/components/EdgeMesh.js +17 -17
- package/src/components/GeometryEdgeVisualizer.js +1 -1
- package/src/components/Grid.js +3 -3
- package/src/components/Line.js +16 -16
- package/src/components/MultiLinePath.js +1 -1
- package/src/components/MultiLineText2D.js +1 -1
- package/src/components/ObjectAxis.js +3 -3
- package/src/components/ObjectOrientedBoundingBox.js +19 -19
- package/src/components/Shape2D.js +7 -7
- package/src/components/Shape3D.js +5 -5
- package/src/components/Text2D.js +3 -3
- package/src/components/UIElement.js +2 -2
- package/src/components/UpdatableMaterialMesh.js +1 -1
- package/src/components/WorldImage.js +4 -4
- package/src/components/mouse_interactors/ObjectRotator.js +2 -2
- package/src/components/sdf_text/SDFText.js +10 -10
- package/src/components/sdf_text/SDFTextBatch.js +24 -24
- package/src/components/sdf_text/TextGlyph.js +2 -2
- package/src/data_textures/RGBADataTexture.js +1 -1
- package/src/data_textures/RGBAFloatDataTexture.js +1 -1
- package/src/data_textures/RGBDataTexture.js +1 -1
- package/src/data_textures/RGBFloatDataTexture.js +1 -1
- package/src/editor/ManipulatorHandle.js +4 -4
- package/src/editor/ObjectEditor.js +2 -2
- package/src/editor/ObjectManipulator.js +3 -3
- package/src/gpu_particles/GPUParticleSystem.js +4 -4
- package/src/gpu_particles/ParticleAttribute.js +4 -4
- package/src/gpu_particles/ParticlePositionAttribute.js +2 -2
- package/src/materials/MedianFilterMaterial.js +1 -1
- package/src/materials/SSAOMaterial.js +5 -5
- package/src/materials/ScreenSpaceTextureMaterial.js +2 -2
- package/src/materials/UnrealBloomComposeMaterial.js +1 -1
- package/src/materials/UnrealBlurMaterial.js +1 -1
- package/src/materials/UnrealComposeMaterial.js +1 -1
- package/src/object_pool/Pool.js +3 -3
- package/src/primitives/Arrow.js +6 -6
- package/src/primitives/Cube.js +2 -2
- package/src/primitives/HorizontalPlane.js +1 -1
- package/src/primitives/Sphere.js +2 -2
- package/src/primitives/VerticalPlane.js +1 -1
- package/src/render_mode/DeferredRender.js +10 -10
- package/src/render_mode/PlanarReflectionsRender.js +3 -3
- package/src/render_mode/TransparencyMixRender.js +1 -1
- package/src/render_utilities/Blitter.js +7 -7
- package/src/render_utilities/GaussianBlurrer.js +3 -3
- package/src/render_utilities/MedianFilter.js +1 -1
- package/src/resource_loader/AbstractLoader.js +1 -1
- package/src/resource_loader/BasisLoader.js +1 -1
- package/src/resource_loader/CubemapLoader.js +1 -1
- package/src/resource_loader/DAELoader.js +1 -1
- package/src/resource_loader/DDSLoader.js +1 -1
- package/src/resource_loader/FileLoader.js +1 -1
- package/src/resource_loader/FontLoader.js +1 -1
- package/src/resource_loader/GLTFDRACOLoader.js +1 -1
- package/src/resource_loader/GLTFLoader.js +1 -1
- package/src/resource_loader/HDRCubeTextureLoader.js +1 -1
- package/src/resource_loader/JSONLoader.js +1 -1
- package/src/resource_loader/OBJLoader.js +1 -1
- package/src/resource_loader/PointArrayLoader.js +6 -6
- package/src/resource_loader/RGBETextureLoader.js +1 -1
- package/src/resource_loader/SVGLoader.js +1 -1
- package/src/resource_loader/TextLoader.js +1 -1
- package/src/static_batcher/GeometryBatch.js +20 -20
- package/src/static_batcher/GeometryBatcher.js +7 -7
- package/src/static_batcher/MeshBatcher.js +8 -8
- package/src/utilities/ArrayUtilities.js +4 -4
- package/src/utilities/CameraUtilities.js +24 -24
- package/src/utilities/EasingFunctions.js +19 -8
- package/src/utilities/FrustumPointFitter.js +55 -55
- package/src/utilities/GeometryUtilities.js +7 -7
- package/src/utilities/ImageUtilities.js +4 -4
- package/src/utilities/MeshSampler.js +33 -33
- package/src/utilities/ModelUtilities.js +2 -2
- package/src/utilities/OMath.js +4 -4
- package/src/utilities/ObjectUtilities.js +4 -4
- package/src/utilities/OrthographicFrustumPointFitter.js +10 -10
- package/src/utilities/PerspectiveFrustumPointFitter.js +55 -55
- package/src/view_components/ApplicationView.js +2 -2
- package/src/view_components/ViewComponent.js +26 -2
- package/src/view_components/ViewComponentManager.js +11 -1
- package/src/view_components/ViewManager.js +20 -2
- package/src/view_components/transition/ActionSequencerBuilder.js +18 -18
- package/src/view_components/transition/DrawIOAnimationSheet.js +20 -20
- package/src/view_components/transition/TransitionTable.js +1 -1
- package/src/view_components/transition/ViewStateTransitionHandler.js +2 -1
package/package.json
CHANGED
package/src/CustomBezierCurve.js
CHANGED
|
@@ -15,7 +15,7 @@ export default class CustomBezierCurve
|
|
|
15
15
|
|
|
16
16
|
build(point_amount)
|
|
17
17
|
{
|
|
18
|
-
|
|
18
|
+
const curve = [];
|
|
19
19
|
for (let i = 0; i < point_amount; i++)
|
|
20
20
|
{
|
|
21
21
|
curve.push(new Vector3().copy(this.get_point_at(i / point_amount)));
|
|
@@ -30,7 +30,7 @@ export default class CustomBezierCurve
|
|
|
30
30
|
this.tmp_points[i].copy(this.original_points[i]);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
const tmp_vec = new Vector3();
|
|
34
34
|
for (let steps = this.tmp_points.length - 1; steps > 0; steps--)
|
|
35
35
|
{
|
|
36
36
|
for (let i = 0; i < steps; i++)
|
package/src/Debug.js
CHANGED
|
@@ -41,7 +41,7 @@ class Debug
|
|
|
41
41
|
|
|
42
42
|
draw_arrow(origin, dir, color = 0xff0000)
|
|
43
43
|
{
|
|
44
|
-
|
|
44
|
+
const arrow = new Arrow(color, dir.length(), dir.clone().normalize());
|
|
45
45
|
arrow.position.copy(origin);
|
|
46
46
|
SceneManager.current.add(arrow);
|
|
47
47
|
return arrow;
|
|
@@ -49,7 +49,7 @@ class Debug
|
|
|
49
49
|
|
|
50
50
|
draw_axis()
|
|
51
51
|
{
|
|
52
|
-
|
|
52
|
+
const axis = new AxisHelper();
|
|
53
53
|
SceneManager.current.add(axis);
|
|
54
54
|
return axis;
|
|
55
55
|
}
|
|
@@ -88,13 +88,13 @@ class Debug
|
|
|
88
88
|
|
|
89
89
|
draw_line(points, color = 0xff0000)
|
|
90
90
|
{
|
|
91
|
-
|
|
91
|
+
const material = new LineBasicMaterial({
|
|
92
92
|
color: color
|
|
93
93
|
});
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
const geometry = new BufferGeometry().setFromPoints(points);
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
const line = new Line(geometry, material);
|
|
98
98
|
line.frustumCulled = false;
|
|
99
99
|
SceneManager.current.add(line);
|
|
100
100
|
return line;
|
|
@@ -106,7 +106,7 @@ class Debug
|
|
|
106
106
|
color = color || 0xff0000;
|
|
107
107
|
pos = pos || new Vector3();
|
|
108
108
|
|
|
109
|
-
|
|
109
|
+
const cube = new Cube(new Vector3(size, size, size), undefined, color);
|
|
110
110
|
cube.position.copy(pos);
|
|
111
111
|
SceneManager.current.add(cube);
|
|
112
112
|
return cube;
|
|
@@ -114,11 +114,11 @@ class Debug
|
|
|
114
114
|
|
|
115
115
|
draw_oriented_cube(from, to, height = 1, color = '#FF0000', depth = 0.1)
|
|
116
116
|
{
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
const size = from.distanceTo(to);
|
|
118
|
+
const cube = new Cube(new Vector3(depth, height, size), undefined, color);
|
|
119
119
|
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
const center = to.clone().sub(from).multiplyScalar(0.5);
|
|
121
|
+
const forward_dir = center.clone().normalize();
|
|
122
122
|
center.add(from);
|
|
123
123
|
|
|
124
124
|
cube.position.copy(center);
|
|
@@ -136,8 +136,8 @@ class Debug
|
|
|
136
136
|
|
|
137
137
|
draw_plane(width, height, color)
|
|
138
138
|
{
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
const geometry = new PlaneBufferGeometry(width, height);
|
|
140
|
+
const material = new ShaderMaterial({
|
|
141
141
|
uniforms: {
|
|
142
142
|
_Color: { value: new Vector4(0, 1, 0, 0.2) }
|
|
143
143
|
},
|
|
@@ -147,7 +147,7 @@ class Debug
|
|
|
147
147
|
depthWrite: false
|
|
148
148
|
});
|
|
149
149
|
|
|
150
|
-
|
|
150
|
+
const plane = new Mesh(geometry, material);
|
|
151
151
|
plane.renderOrder = -10000;
|
|
152
152
|
SceneManager.current.add(plane);
|
|
153
153
|
return plane;
|
|
@@ -158,8 +158,8 @@ class Debug
|
|
|
158
158
|
size = size || 1;
|
|
159
159
|
color = color || 0xff0000;
|
|
160
160
|
|
|
161
|
-
|
|
162
|
-
|
|
161
|
+
const box = new Box3().setFromCenterAndSize(new Vector3(), new Vector3(size, size, size));
|
|
162
|
+
const helper = new Box3Helper(box, color);
|
|
163
163
|
helper.position.copy(pos || new Vector3());
|
|
164
164
|
return helper;
|
|
165
165
|
}
|
|
@@ -170,7 +170,7 @@ class Debug
|
|
|
170
170
|
color = color || 0xff0000;
|
|
171
171
|
pos = pos || new Vector3();
|
|
172
172
|
|
|
173
|
-
|
|
173
|
+
const sphere = new Sphere(size, color);
|
|
174
174
|
sphere.position.copy(pos);
|
|
175
175
|
SceneManager.current.add(sphere);
|
|
176
176
|
return sphere;
|
|
@@ -178,10 +178,10 @@ class Debug
|
|
|
178
178
|
|
|
179
179
|
draw_point_array(input_points, open = false, color = 0xff0000)
|
|
180
180
|
{
|
|
181
|
-
|
|
181
|
+
const catmull = new CatmullRomCurve3(input_points, open);
|
|
182
182
|
catmull.updateArcLengths();
|
|
183
|
-
|
|
184
|
-
|
|
183
|
+
const points = catmull.getSpacedPoints(200);
|
|
184
|
+
const line_helper = this.draw_line(points, 0x00ff00);
|
|
185
185
|
// line_helper.position.y = 1.5;
|
|
186
186
|
return line_helper;
|
|
187
187
|
}
|
|
@@ -189,9 +189,9 @@ class Debug
|
|
|
189
189
|
draw_sphere_helper(sphere, color)
|
|
190
190
|
{
|
|
191
191
|
color = color || 0xff0000;
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
192
|
+
const geometry = new SphereGeometry(sphere.radius, 32, 32);
|
|
193
|
+
const material = new MeshBasicMaterial({ color: color });
|
|
194
|
+
const sphere_mesh = new Mesh(geometry, material);
|
|
195
195
|
sphere_mesh.position.copy(sphere.center);
|
|
196
196
|
SceneManager.current.add(sphere_mesh);
|
|
197
197
|
return sphere_mesh;
|
|
@@ -199,8 +199,8 @@ class Debug
|
|
|
199
199
|
|
|
200
200
|
draw_math_sphere(sphere)
|
|
201
201
|
{
|
|
202
|
-
|
|
203
|
-
|
|
202
|
+
const geometry = new SphereGeometry(sphere.radius, 32, 32);
|
|
203
|
+
const material = new ShaderMaterial({
|
|
204
204
|
uniforms: {
|
|
205
205
|
_Color: { value: new Vector4(1, 0, 0, 0.2) }
|
|
206
206
|
},
|
|
@@ -209,20 +209,20 @@ class Debug
|
|
|
209
209
|
transparent: true
|
|
210
210
|
});
|
|
211
211
|
// var material = new MeshBasicMaterial( {color: 0xff0000, transparent = true} );
|
|
212
|
-
|
|
212
|
+
const sphere1 = new Mesh(geometry, material);
|
|
213
213
|
sphere1.position.copy(sphere.center);
|
|
214
214
|
SceneManager.current.add(sphere1);
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
draw_bounding_box(bb)
|
|
218
218
|
{
|
|
219
|
-
|
|
219
|
+
const helper = new Box3Helper(bb, 0xffff00);
|
|
220
220
|
SceneManager.current.add(helper);
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
draw_curve(curve, options)
|
|
224
224
|
{
|
|
225
|
-
|
|
225
|
+
const offset = new Vector3(0, 0, 0);
|
|
226
226
|
if (options)
|
|
227
227
|
{
|
|
228
228
|
offset.y = options.offset || 0;
|
|
@@ -236,7 +236,7 @@ class Debug
|
|
|
236
236
|
|
|
237
237
|
draw_texture(tex, w, h)
|
|
238
238
|
{
|
|
239
|
-
|
|
239
|
+
const mesh = new Mesh(new PlaneBufferGeometry(1, 1), new ScreenSpaceTextureMaterial());
|
|
240
240
|
this.display_texture_meshes.push(mesh);
|
|
241
241
|
this.scene.add(mesh);
|
|
242
242
|
|
package/src/EventManager.js
CHANGED
package/src/Graphics.js
CHANGED
|
@@ -201,7 +201,7 @@ class Graphics
|
|
|
201
201
|
|
|
202
202
|
on_resize(entries)
|
|
203
203
|
{
|
|
204
|
-
for (
|
|
204
|
+
for (const entry of entries)
|
|
205
205
|
{
|
|
206
206
|
Screen.dpr = Configuration.dpr;
|
|
207
207
|
Screen.update_position(entry.contentRect.x, entry.contentRect.y);
|
|
@@ -242,17 +242,17 @@ class Graphics
|
|
|
242
242
|
{
|
|
243
243
|
// const ctx = this;
|
|
244
244
|
|
|
245
|
-
|
|
246
|
-
|
|
245
|
+
const old_width = Screen.width;
|
|
246
|
+
const old_height = Screen.height;
|
|
247
247
|
|
|
248
|
-
|
|
249
|
-
|
|
248
|
+
const new_width = width;
|
|
249
|
+
const new_height = height;
|
|
250
250
|
|
|
251
|
-
|
|
252
|
-
|
|
251
|
+
const tile_width = 1024;
|
|
252
|
+
const tile_height = 1024;
|
|
253
253
|
|
|
254
|
-
|
|
255
|
-
|
|
254
|
+
const divisions_x = parseInt(Math.ceil(new_width / tile_width));
|
|
255
|
+
const divisions_y = parseInt(Math.ceil(new_height / tile_height));
|
|
256
256
|
|
|
257
257
|
Screen.update_size(tile_width, tile_height);
|
|
258
258
|
|
|
@@ -260,8 +260,8 @@ class Graphics
|
|
|
260
260
|
|
|
261
261
|
this._renderer.setSize(tile_width, tile_height, false);
|
|
262
262
|
|
|
263
|
-
|
|
264
|
-
|
|
263
|
+
const canvas_2d = document.createElement('canvas');
|
|
264
|
+
const ctx_2D = canvas_2d.getContext('2d');
|
|
265
265
|
|
|
266
266
|
ctx_2D.canvas.width = new_width;
|
|
267
267
|
ctx_2D.canvas.height = new_height;
|
|
@@ -300,7 +300,7 @@ class Graphics
|
|
|
300
300
|
|
|
301
301
|
download_screenshot(blob)
|
|
302
302
|
{
|
|
303
|
-
|
|
303
|
+
const link = document.createElement('a');
|
|
304
304
|
link.download = 'Snapshot.png';
|
|
305
305
|
|
|
306
306
|
link.href = URL.createObjectURL(blob);
|
package/src/KeyboardInput.js
CHANGED
package/src/OS.js
CHANGED
|
@@ -23,11 +23,11 @@ class OS
|
|
|
23
23
|
|
|
24
24
|
get_os()
|
|
25
25
|
{
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
const userAgent = window.navigator.userAgent;
|
|
27
|
+
const platform = window.navigator.platform;
|
|
28
|
+
const macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'];
|
|
29
|
+
const windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'];
|
|
30
|
+
const iosPlatforms = ['iPhone', 'iPad', 'iPod'];
|
|
31
31
|
let os = null;
|
|
32
32
|
|
|
33
33
|
if (macosPlatforms.indexOf(platform) !== -1)
|
package/src/UI.js
CHANGED
|
@@ -18,7 +18,7 @@ export default class ActionSequencer
|
|
|
18
18
|
|
|
19
19
|
this.channels = {};
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
const channel_names = Object.keys(context);
|
|
22
22
|
for (let i = 0; i < channel_names.length; i++)
|
|
23
23
|
{
|
|
24
24
|
this.channels[channel_names[i]] = [];
|
|
@@ -44,7 +44,7 @@ export default class ActionSequencer
|
|
|
44
44
|
|
|
45
45
|
skip()
|
|
46
46
|
{
|
|
47
|
-
|
|
47
|
+
const duration = this.get_duration();
|
|
48
48
|
this.__play_clips(this.elapsed_time, duration + 0.0001);
|
|
49
49
|
this.elapsed_time = duration;
|
|
50
50
|
}
|
|
@@ -94,7 +94,7 @@ export default class ActionSequencer
|
|
|
94
94
|
{
|
|
95
95
|
if (use_dynamic_from_value)
|
|
96
96
|
{
|
|
97
|
-
|
|
97
|
+
const keyframes = this.channels[interpolator.attribute_name];
|
|
98
98
|
|
|
99
99
|
if (keyframes === undefined)
|
|
100
100
|
{
|
|
@@ -111,7 +111,7 @@ export default class ActionSequencer
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
const keyframe = {
|
|
115
115
|
from: from,
|
|
116
116
|
to: to,
|
|
117
117
|
interpolator: interpolator
|
|
@@ -123,7 +123,7 @@ export default class ActionSequencer
|
|
|
123
123
|
|
|
124
124
|
get_property_target_value(name)
|
|
125
125
|
{
|
|
126
|
-
|
|
126
|
+
const keyframe = this.__get_nearest_keyframe(name, this.elapsed_time);
|
|
127
127
|
|
|
128
128
|
if (this.elapsed_time < keyframe.from)
|
|
129
129
|
{
|
|
@@ -149,12 +149,12 @@ export default class ActionSequencer
|
|
|
149
149
|
this.action_events[i].action.trigger();
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
|
-
|
|
152
|
+
const channel_names = Object.keys(this.initial_context);
|
|
153
153
|
|
|
154
154
|
for (let i = 0; i < channel_names.length; i++)
|
|
155
155
|
{
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
const name = channel_names[i];
|
|
157
|
+
const keyframe = this.__get_nearest_keyframe(name, from);
|
|
158
158
|
this.context[name] = this.evaluate_keyframe(keyframe, from);
|
|
159
159
|
}
|
|
160
160
|
}
|
|
@@ -165,6 +165,11 @@ export default class ActionSequencer
|
|
|
165
165
|
return keyframe.interpolator.evaluate(TMath.clamp(this.tmp_t, 0, 1));
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
+
get_keyframes(channel_name)
|
|
169
|
+
{
|
|
170
|
+
return this.channels[channel_name];
|
|
171
|
+
}
|
|
172
|
+
|
|
168
173
|
__linear_map_01(value,
|
|
169
174
|
from_range_start_value,
|
|
170
175
|
from_range_end_value)
|
|
@@ -176,12 +181,12 @@ export default class ActionSequencer
|
|
|
176
181
|
{
|
|
177
182
|
let closest = undefined;
|
|
178
183
|
let min_time = 9999999;
|
|
179
|
-
|
|
184
|
+
const keyframes = this.channels[channel_name];
|
|
180
185
|
for (let i = 0; i < keyframes.length; i++)
|
|
181
186
|
{
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
187
|
+
const keyframe = keyframes[i];
|
|
188
|
+
const middle_time = (keyframe.to - keyframe.from) / 2 + keyframe.from;
|
|
189
|
+
const distance_to_middle_time = Math.abs(time - middle_time);
|
|
185
190
|
|
|
186
191
|
if (distance_to_middle_time < min_time)
|
|
187
192
|
{
|
|
@@ -19,9 +19,9 @@ export default class CanvasDrawer
|
|
|
19
19
|
{
|
|
20
20
|
if (this.__textHeight == null || this.uses_dynamic_font)
|
|
21
21
|
{
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
const body = document.getElementsByTagName('body')[0];
|
|
23
|
+
const dummy = document.createElement('div');
|
|
24
|
+
const dummyText = document.createTextNode('MÉqgOLAKTAL');
|
|
25
25
|
dummy.appendChild(dummyText);
|
|
26
26
|
dummy.setAttribute('style', `font:${fontStyle};position:absolute;top:0;left:0`);
|
|
27
27
|
body.appendChild(dummy);
|
|
@@ -33,7 +33,7 @@ export default class CanvasDrawer
|
|
|
33
33
|
|
|
34
34
|
get_text_size(text, font = '24px Arial')
|
|
35
35
|
{
|
|
36
|
-
|
|
36
|
+
const size = new Vector2();
|
|
37
37
|
this.ctx.font = font;
|
|
38
38
|
size.x = Math.ceil(this.ctx.measureText(text).width);
|
|
39
39
|
size.y = Math.ceil(this.getFontHeight(font));
|
|
@@ -51,8 +51,8 @@ export default class CanvasDrawer
|
|
|
51
51
|
|
|
52
52
|
draw_on_texture(text, ctxOptions)
|
|
53
53
|
{
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
const canvas = this.draw_canvas(text, ctxOptions);
|
|
55
|
+
const canvas_texture = new CanvasTexture(canvas, UVMapping,
|
|
56
56
|
ClampToEdgeWrapping,
|
|
57
57
|
ClampToEdgeWrapping,
|
|
58
58
|
NearestFilter,
|
|
@@ -82,8 +82,8 @@ export default class CanvasDrawer
|
|
|
82
82
|
}
|
|
83
83
|
else
|
|
84
84
|
{
|
|
85
|
-
|
|
86
|
-
for (
|
|
85
|
+
const defaultRadius = { tl: 0, tr: 0, br: 0, bl: 0 };
|
|
86
|
+
for (const side in defaultRadius)
|
|
87
87
|
{
|
|
88
88
|
radius[side] = radius[side] || defaultRadius[side];
|
|
89
89
|
}
|
|
@@ -13,10 +13,10 @@ export default class MultiLineTextDrawer extends CanvasDrawer
|
|
|
13
13
|
__draw(text_array, ctxOptions, canvas, ctx)
|
|
14
14
|
{
|
|
15
15
|
ctx.font = ctxOptions.font;
|
|
16
|
-
|
|
16
|
+
const text_size = new Vector2();
|
|
17
17
|
for (let i = 0; i < text_array.length; i++)
|
|
18
18
|
{
|
|
19
|
-
|
|
19
|
+
const new_size = this.get_text_size(text_array[i], ctxOptions.font);
|
|
20
20
|
console.log(new_size.clone());
|
|
21
21
|
text_size.x = Math.max(text_size.x, new_size.x);
|
|
22
22
|
text_size.y += Math.max(text_size.y, new_size.y);
|
|
@@ -39,7 +39,7 @@ export default class MultiLineTextDrawer extends CanvasDrawer
|
|
|
39
39
|
ctx.textBaseline = 'middle';
|
|
40
40
|
ctx.textAlignment = 'left';
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
const word_height = canvas.height / text_array.length;
|
|
43
43
|
for (let i = 0; i < text_array.length; i++)
|
|
44
44
|
{
|
|
45
45
|
// let height = i / (text_array.length);
|
|
@@ -15,7 +15,7 @@ export default class SimpleTextDrawer extends CanvasDrawer
|
|
|
15
15
|
{
|
|
16
16
|
ctx.font = ctxOptions.font;
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
const text_size = this.get_text_size(text, ctxOptions.font);
|
|
19
19
|
// canvas.width = Math.ceilPowerOfTwo(text_size.x+this.text_margin.x*2);
|
|
20
20
|
// canvas.height = Math.ceilPowerOfTwo(text_size.y+ this.text_margin.y*2);
|
|
21
21
|
canvas.width = Math.ceil(text_size.x + this.text_margin.x * 2);
|
|
@@ -45,8 +45,8 @@ export default class EdgeMesh extends Object3D
|
|
|
45
45
|
depthWrite: false
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
const edges_geometry = this.__get_edges_geometry(this.__get_edges(buffer_geometry));
|
|
49
|
+
const corners_geometry = this.__get_corners_geometry(buffer_geometry.getAttribute('position'));
|
|
50
50
|
|
|
51
51
|
this.edges_mesh = new Mesh(edges_geometry, this.edges_material);
|
|
52
52
|
this.corners_mesh = new Mesh(corners_geometry, this.corners_material);
|
|
@@ -59,11 +59,11 @@ export default class EdgeMesh extends Object3D
|
|
|
59
59
|
|
|
60
60
|
__get_edges(cube_geometry)
|
|
61
61
|
{
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
const edges = new EdgesGeometry(cube_geometry);
|
|
63
|
+
const line = new LineSegments(edges, new LineBasicMaterial());
|
|
64
|
+
const points_array = line.geometry.attributes.position.array;
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
const points = [];
|
|
67
67
|
for (let i = 0; i < points_array.length; i += 3)
|
|
68
68
|
{
|
|
69
69
|
points.push(new Vector3(points_array[i], points_array[i + 1], points_array[i + 2]));
|
|
@@ -78,12 +78,12 @@ export default class EdgeMesh extends Object3D
|
|
|
78
78
|
|
|
79
79
|
__get_edges_geometry(points)
|
|
80
80
|
{
|
|
81
|
-
|
|
81
|
+
const buffer_geometries = [];
|
|
82
82
|
for (let i = 0; i < points.length; i += 2)
|
|
83
83
|
{
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
const dir = points[i + 1].clone().sub(points[i]).normalize();
|
|
85
|
+
const geometry = new PlaneBufferGeometry(1, 1);
|
|
86
|
+
const vertices = geometry.getAttribute('position');
|
|
87
87
|
// top right
|
|
88
88
|
vertices.array[0] = points[i].x;
|
|
89
89
|
vertices.array[1] = points[i].y;
|
|
@@ -102,14 +102,14 @@ export default class EdgeMesh extends Object3D
|
|
|
102
102
|
vertices.array[10] = points[i + 1].y;
|
|
103
103
|
vertices.array[11] = points[i + 1].z;
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
const dirs = [];
|
|
106
106
|
for (let d = 0; d < vertices.count; d++)
|
|
107
107
|
{
|
|
108
108
|
dirs.push(dir.x);
|
|
109
109
|
dirs.push(dir.y);
|
|
110
110
|
dirs.push(dir.z);
|
|
111
111
|
}
|
|
112
|
-
|
|
112
|
+
const dir_array = new Float32Array(dirs);
|
|
113
113
|
geometry.setAttribute('tangent', new BufferAttribute(dir_array, 3));
|
|
114
114
|
buffer_geometries.push(geometry);
|
|
115
115
|
}
|
|
@@ -119,19 +119,19 @@ export default class EdgeMesh extends Object3D
|
|
|
119
119
|
|
|
120
120
|
__get_corners_geometry(geometry_vertices)
|
|
121
121
|
{
|
|
122
|
-
|
|
122
|
+
const circle_buffer_geometries = [];
|
|
123
123
|
for (let i = 0; i < geometry_vertices.count; i++)
|
|
124
124
|
{
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
125
|
+
const plane_geometry = new PlaneBufferGeometry(1, 1);
|
|
126
|
+
const plane_vertices = plane_geometry.getAttribute('position');
|
|
127
|
+
const w_pos = [];
|
|
128
128
|
for (let d = 0; d < plane_vertices.count; d++)
|
|
129
129
|
{
|
|
130
130
|
w_pos.push(geometry_vertices.array[i * 3 + 0]);
|
|
131
131
|
w_pos.push(geometry_vertices.array[i * 3 + 1]);
|
|
132
132
|
w_pos.push(geometry_vertices.array[i * 3 + 2]);
|
|
133
133
|
}
|
|
134
|
-
|
|
134
|
+
const pos_array = new Float32Array(w_pos);
|
|
135
135
|
plane_geometry.setAttribute('w_pos', new BufferAttribute(pos_array, 3));
|
|
136
136
|
circle_buffer_geometries.push(plane_geometry);
|
|
137
137
|
}
|
|
@@ -12,7 +12,7 @@ export default class GeometryEdgeVisualizer extends Mesh
|
|
|
12
12
|
{
|
|
13
13
|
line_color = line_color || '#91EE91';
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
const material = new ShaderMaterial({
|
|
16
16
|
uniforms: {
|
|
17
17
|
_Color: { value: new Color('#CC3333') },
|
|
18
18
|
_LineColor: { value: new Color(line_color) },
|
package/src/components/Grid.js
CHANGED
|
@@ -11,7 +11,7 @@ export default class Grid extends Mesh
|
|
|
11
11
|
{
|
|
12
12
|
constructor()
|
|
13
13
|
{
|
|
14
|
-
|
|
14
|
+
const material = new ShaderMaterial({
|
|
15
15
|
uniforms: {
|
|
16
16
|
_Color: { value: new Color('#919191') }
|
|
17
17
|
},
|
|
@@ -22,9 +22,9 @@ export default class Grid extends Mesh
|
|
|
22
22
|
depthWrite: false
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
const plane_geometry = new PlaneBufferGeometry(100, 100, 100, 100);
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
const non_indexed_geometry = GeometryUtilities.convert_to_non_indexed_geometry(plane_geometry);
|
|
28
28
|
|
|
29
29
|
super(non_indexed_geometry, material);
|
|
30
30
|
|
package/src/components/Line.js
CHANGED
|
@@ -11,14 +11,14 @@ export default class Line extends Mesh
|
|
|
11
11
|
{
|
|
12
12
|
constructor(points)
|
|
13
13
|
{
|
|
14
|
-
|
|
14
|
+
const geometry = new BufferGeometry();
|
|
15
15
|
geometry.setAttribute('position', new BufferAttribute(new Float32Array([]), 3));
|
|
16
16
|
geometry.setAttribute('next_position', new BufferAttribute(new Float32Array([]), 3));
|
|
17
17
|
geometry.setAttribute('previous_position', new BufferAttribute(new Float32Array([]), 3));
|
|
18
18
|
geometry.setAttribute('orientation', new BufferAttribute(new Float32Array([]), 1));
|
|
19
19
|
geometry.setAttribute('coverage', new BufferAttribute(new Float32Array([]), 1));
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
const material = new ShaderMaterial({
|
|
22
22
|
uniforms: {
|
|
23
23
|
_Thickness: { value: 0.2 },
|
|
24
24
|
_Length: { value: 0 },
|
|
@@ -43,11 +43,11 @@ export default class Line extends Mesh
|
|
|
43
43
|
|
|
44
44
|
setup(points)
|
|
45
45
|
{
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
const vertices = [];
|
|
47
|
+
const next_position = [];
|
|
48
|
+
const previous_position = [];
|
|
49
|
+
const orientation = [];
|
|
50
|
+
const coverage = [];
|
|
51
51
|
let accumulated_length = 0;
|
|
52
52
|
|
|
53
53
|
for (let i = 0; i < points.length; i++)
|
|
@@ -62,7 +62,7 @@ export default class Line extends Mesh
|
|
|
62
62
|
vertices.push(points[i].z);
|
|
63
63
|
orientation.push(-1);
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
const next_point = this.__get_next_position(points, i);
|
|
66
66
|
next_position.push(next_point.x);
|
|
67
67
|
next_position.push(next_point.y);
|
|
68
68
|
next_position.push(next_point.z);
|
|
@@ -71,7 +71,7 @@ export default class Line extends Mesh
|
|
|
71
71
|
next_position.push(next_point.y);
|
|
72
72
|
next_position.push(next_point.z);
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
const previous_point = this.__get_previous_position(points, i);
|
|
75
75
|
previous_position.push(previous_point.x);
|
|
76
76
|
previous_position.push(previous_point.y);
|
|
77
77
|
previous_position.push(previous_point.z);
|
|
@@ -88,16 +88,16 @@ export default class Line extends Mesh
|
|
|
88
88
|
accumulated_length += points[i].distanceTo(next_point);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
91
|
+
const vertexList = new Float32Array(vertices);
|
|
92
|
+
const nextPositionList = new Float32Array(next_position);
|
|
93
|
+
const previousPositionList = new Float32Array(previous_position);
|
|
94
|
+
const orientationList = new Float32Array(orientation);
|
|
95
|
+
const coverageList = new Float32Array(coverage);
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
const indices = [];
|
|
98
98
|
for (let i = 0; i < ((vertexList.length / 3) - 2) / 2; i++)
|
|
99
99
|
{
|
|
100
|
-
|
|
100
|
+
const index = (i * 2) + 1;
|
|
101
101
|
indices.push(index);
|
|
102
102
|
indices.push(index + 1);
|
|
103
103
|
indices.push(index - 1);
|