@needle-tools/engine 4.3.2-beta.1 → 4.3.2-beta.3
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/CHANGELOG.md +6 -0
- package/dist/needle-engine.bundle.js +95 -14
- package/dist/needle-engine.bundle.light.js +95 -14
- package/dist/needle-engine.bundle.light.min.js +5 -5
- package/dist/needle-engine.bundle.light.umd.cjs +5 -5
- package/dist/needle-engine.bundle.min.js +5 -5
- package/dist/needle-engine.bundle.umd.cjs +5 -5
- package/lib/engine/engine_context.d.ts +2 -1
- package/lib/engine/engine_context.js +1 -1
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_gizmos.d.ts +84 -3
- package/lib/engine/engine_gizmos.js +88 -7
- package/lib/engine/engine_gizmos.js.map +1 -1
- package/lib/engine/engine_texture.d.ts +2 -1
- package/lib/engine/engine_texture.js.map +1 -1
- package/lib/engine/engine_tonemapping.js +2 -2
- package/package.json +1 -1
- package/src/engine/engine_context.ts +3 -2
- package/src/engine/engine_gizmos.ts +89 -8
- package/src/engine/engine_texture.ts +3 -2
- package/src/engine/engine_tonemapping.ts +2 -2
|
@@ -81,8 +81,8 @@ vec3 _agx(vec3 val) {
|
|
|
81
81
|
0.0784335999999992, 0.878468636469772, 0.0784336,
|
|
82
82
|
0.0792237451477643, 0.0791661274605434, 0.879142973793104);
|
|
83
83
|
|
|
84
|
-
const float min_ev = -12.
|
|
85
|
-
const float max_ev = 4.
|
|
84
|
+
const float min_ev = -12.47393;
|
|
85
|
+
const float max_ev = 4.026069;
|
|
86
86
|
|
|
87
87
|
// val = pow(val, vec3(2.2));
|
|
88
88
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@needle-tools/engine",
|
|
3
|
-
"version": "4.3.2-beta.
|
|
3
|
+
"version": "4.3.2-beta.3",
|
|
4
4
|
"description": "Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in",
|
|
5
5
|
"main": "dist/needle-engine.min.js",
|
|
6
6
|
"exports": {
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
/** @ts-ignore (not yet in types?) */
|
|
11
11
|
import { BasicNodeLibrary } from "three";
|
|
12
12
|
import * as Stats from 'three/examples/jsm/libs/stats.module.js';
|
|
13
|
+
import type { EffectComposer as ThreeEffectComposer } from "three/examples/jsm/postprocessing/EffectComposer.js";
|
|
13
14
|
import { nodeFrame } from "three/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js";
|
|
14
15
|
|
|
15
16
|
import { isDevEnvironment, LogType, showBalloonError, showBalloonMessage } from './debug/index.js';
|
|
@@ -317,7 +318,7 @@ export class Context implements IContext {
|
|
|
317
318
|
|
|
318
319
|
scene: Scene;
|
|
319
320
|
renderer!: WebGLRenderer;
|
|
320
|
-
composer: EffectComposer | null = null;
|
|
321
|
+
composer: EffectComposer | ThreeEffectComposer | null = null;
|
|
321
322
|
|
|
322
323
|
// all scripts
|
|
323
324
|
readonly scripts: IComponent[] = [];
|
|
@@ -1450,7 +1451,7 @@ export class Context implements IContext {
|
|
|
1450
1451
|
|
|
1451
1452
|
if (this.composer && !this.isInXR) {
|
|
1452
1453
|
// if a camera is passed in we need to check if we need to update the composer's camera
|
|
1453
|
-
if (camera) {
|
|
1454
|
+
if (camera && "setMainCamera" in this.composer) {
|
|
1454
1455
|
const currentPassesCamera = this.composer.passes[0]?.mainCamera;
|
|
1455
1456
|
if (currentPassesCamera != camera)
|
|
1456
1457
|
this.composer.setMainCamera(camera);
|
|
@@ -44,9 +44,23 @@ export class Gizmos {
|
|
|
44
44
|
return obj[$cacheSymbol] !== undefined;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
/** Set visibility of all currently rendered gizmos */
|
|
48
|
+
static setVisible(visible: boolean) {
|
|
49
|
+
for (const obj of Internal.timedObjectsBuffer) {
|
|
50
|
+
obj.visible = visible;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
47
54
|
/**
|
|
48
55
|
* Draw a label in the scene or attached to an object (if a parent is provided)
|
|
49
|
-
* @
|
|
56
|
+
* @param position the position of the label in world space
|
|
57
|
+
* @param text the text of the label
|
|
58
|
+
* @param size the size of the label in world space
|
|
59
|
+
* @param duration the duration in seconds the label will be rendered. If 0 it will be rendered for one frame
|
|
60
|
+
* @param color the color of the label
|
|
61
|
+
* @param backgroundColor the background color of the label
|
|
62
|
+
* @param parent the parent object to attach the label to. If no parent is provided the label will be attached to the scene
|
|
63
|
+
* @returns a handle to the label that can be used to update the text
|
|
50
64
|
*/
|
|
51
65
|
static DrawLabel(position: Vec3, text: string, size: number = .05, duration: number = 0, color?: ColorRepresentation, backgroundColor?: ColorRepresentation | ColorWithAlpha, parent?: Object3D,) {
|
|
52
66
|
if (!Gizmos.enabled) return null;
|
|
@@ -60,6 +74,14 @@ export class Gizmos {
|
|
|
60
74
|
return element as LabelHandle;
|
|
61
75
|
}
|
|
62
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Draw a ray gizmo in the scene
|
|
79
|
+
* @param origin the origin of the ray in world space
|
|
80
|
+
* @param dir the direction of the ray in world space
|
|
81
|
+
* @param color the color of the ray
|
|
82
|
+
* @param duration the duration in seconds the ray will be rendered. If 0 it will be rendered for one frame
|
|
83
|
+
* @param depthTest if true the ray will be rendered with depth test
|
|
84
|
+
*/
|
|
63
85
|
static DrawRay(origin: Vec3, dir: Vec3, color: ColorRepresentation = defaultColor, duration: number = 0, depthTest: boolean = true) {
|
|
64
86
|
if (!Gizmos.enabled) return;
|
|
65
87
|
const obj = Internal.getLine(duration);
|
|
@@ -73,6 +95,15 @@ export class Gizmos {
|
|
|
73
95
|
obj.material["depthWrite"] = false;
|
|
74
96
|
}
|
|
75
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Draw a line gizmo in the scene
|
|
100
|
+
* @param pt0 the start point of the line in world space
|
|
101
|
+
* @param pt1 the end point of the line in world space
|
|
102
|
+
* @param color the color of the line
|
|
103
|
+
* @param duration the duration in seconds the line will be rendered. If 0 it will be rendered for one frame
|
|
104
|
+
* @param depthTest if true the line will be rendered with depth test
|
|
105
|
+
* @param lengthFactor the length of the line. Default is 1
|
|
106
|
+
*/
|
|
76
107
|
static DrawDirection(pt: Vec3, direction: Vec3 | Vec4, color: ColorRepresentation = defaultColor, duration: number = 0, depthTest: boolean = true, lengthFactor: number = 1) {
|
|
77
108
|
if (!Gizmos.enabled) return;
|
|
78
109
|
const obj = Internal.getLine(duration);
|
|
@@ -95,6 +126,14 @@ export class Gizmos {
|
|
|
95
126
|
|
|
96
127
|
}
|
|
97
128
|
|
|
129
|
+
/**
|
|
130
|
+
* Draw a line gizmo in the scene
|
|
131
|
+
* @param pt0 the start point of the line in world space
|
|
132
|
+
* @param pt1 the end point of the line in world space
|
|
133
|
+
* @param color the color of the line
|
|
134
|
+
* @param duration the duration in seconds the line will be rendered. If 0 it will be rendered for one frame
|
|
135
|
+
* @param depthTest if true the line will be rendered with depth test
|
|
136
|
+
*/
|
|
98
137
|
static DrawLine(pt0: Vec3, pt1: Vec3, color: ColorRepresentation = defaultColor, duration: number = 0, depthTest: boolean = true) {
|
|
99
138
|
if (!Gizmos.enabled) return;
|
|
100
139
|
const obj = Internal.getLine(duration);
|
|
@@ -108,6 +147,15 @@ export class Gizmos {
|
|
|
108
147
|
obj.material["fog"] = false;
|
|
109
148
|
}
|
|
110
149
|
|
|
150
|
+
/**
|
|
151
|
+
* Draw a 2D circle gizmo in the scene
|
|
152
|
+
* @param pt0 the center of the circle in world space
|
|
153
|
+
* @param normal the normal of the circle in world space
|
|
154
|
+
* @param radius the radius of the circle in world space
|
|
155
|
+
* @param color the color of the circle
|
|
156
|
+
* @param duration the duration in seconds the circle will be rendered. If 0 it will be rendered for one frame
|
|
157
|
+
* @param depthTest if true the circle will be rendered with depth test
|
|
158
|
+
*/
|
|
111
159
|
static DrawCircle(pt0: Vec3, normal: Vec3, radius: number, color: ColorRepresentation = defaultColor, duration: number = 0, depthTest: boolean = true) {
|
|
112
160
|
if (!Gizmos.enabled) return;
|
|
113
161
|
const obj = Internal.getCircle(duration);
|
|
@@ -120,6 +168,14 @@ export class Gizmos {
|
|
|
120
168
|
obj.material["fog"] = false;
|
|
121
169
|
}
|
|
122
170
|
|
|
171
|
+
/**
|
|
172
|
+
* Draw a 3D wiremesh sphere gizmo in the scene
|
|
173
|
+
* @param center the center of the sphere in world space
|
|
174
|
+
* @param radius the radius of the sphere in world space
|
|
175
|
+
* @param color the color of the sphere
|
|
176
|
+
* @param duration the duration in seconds the sphere will be rendered. If 0 it will be rendered for one frame
|
|
177
|
+
* @param depthTest if true the sphere will be rendered with depth test
|
|
178
|
+
*/
|
|
123
179
|
static DrawWireSphere(center: Vec3, radius: number, color: ColorRepresentation = defaultColor, duration: number = 0, depthTest: boolean = true) {
|
|
124
180
|
if (!Gizmos.enabled) return;
|
|
125
181
|
const obj = Internal.getSphere(radius, duration, true);
|
|
@@ -130,6 +186,14 @@ export class Gizmos {
|
|
|
130
186
|
obj.material["fog"] = false;
|
|
131
187
|
}
|
|
132
188
|
|
|
189
|
+
/**
|
|
190
|
+
* Draw a 3D sphere gizmo in the scene
|
|
191
|
+
* @param center the center of the sphere in world space
|
|
192
|
+
* @param radius the radius of the sphere in world space
|
|
193
|
+
* @param color the color of the sphere
|
|
194
|
+
* @param duration the duration in seconds the sphere will be rendered. If 0 it will be rendered for one frame
|
|
195
|
+
* @param depthTest if true the sphere will be rendered with depth test
|
|
196
|
+
*/
|
|
133
197
|
static DrawSphere(center: Vec3, radius: number, color: ColorRepresentation = defaultColor, duration: number = 0, depthTest: boolean = true) {
|
|
134
198
|
if (!Gizmos.enabled) return;
|
|
135
199
|
const obj = Internal.getSphere(radius, duration, false);
|
|
@@ -139,6 +203,14 @@ export class Gizmos {
|
|
|
139
203
|
obj.material["depthWrite"] = false;
|
|
140
204
|
}
|
|
141
205
|
|
|
206
|
+
/**
|
|
207
|
+
* Draw a 3D wiremesh box gizmo in the scene
|
|
208
|
+
* @param center the center of the box in world space
|
|
209
|
+
* @param size the size of the box in world space
|
|
210
|
+
* @param color the color of the box
|
|
211
|
+
* @param duration the duration in seconds the box will be rendered. If 0 it will be rendered for one frame
|
|
212
|
+
* @param depthTest if true the box will be rendered with depth test
|
|
213
|
+
*/
|
|
142
214
|
static DrawWireBox(center: Vec3, size: Vec3, color: ColorRepresentation = defaultColor, duration: number = 0, depthTest: boolean = true) {
|
|
143
215
|
if (!Gizmos.enabled) return;
|
|
144
216
|
const obj = Internal.getBox(duration);
|
|
@@ -151,6 +223,13 @@ export class Gizmos {
|
|
|
151
223
|
obj.material["fog"] = false;
|
|
152
224
|
}
|
|
153
225
|
|
|
226
|
+
/**
|
|
227
|
+
* Draw a 3D wiremesh box gizmo in the scene
|
|
228
|
+
* @param box the box in world space
|
|
229
|
+
* @param color the color of the box
|
|
230
|
+
* @param duration the duration in seconds the box will be rendered. If 0 it will be rendered for one frame
|
|
231
|
+
* @param depthTest if true the box will be rendered with depth test
|
|
232
|
+
*/
|
|
154
233
|
static DrawWireBox3(box: Box3, color: ColorRepresentation = defaultColor, duration: number = 0, depthTest: boolean = true) {
|
|
155
234
|
if (!Gizmos.enabled) return;
|
|
156
235
|
const obj = Internal.getBox(duration);
|
|
@@ -164,6 +243,15 @@ export class Gizmos {
|
|
|
164
243
|
}
|
|
165
244
|
|
|
166
245
|
private static _up = new Vector3(0, 1, 0);
|
|
246
|
+
/**
|
|
247
|
+
* Draw an arrow gizmo in the scene
|
|
248
|
+
* @param pt0 the start point of the arrow in world space
|
|
249
|
+
* @param pt1 the end point of the arrow in world space
|
|
250
|
+
* @param color the color of the arrow
|
|
251
|
+
* @param duration the duration in seconds the arrow will be rendered. If 0 it will be rendered for one frame
|
|
252
|
+
* @param depthTest if true the arrow will be rendered with depth test
|
|
253
|
+
* @param wireframe if true the arrow will be rendered as wireframe
|
|
254
|
+
*/
|
|
167
255
|
static DrawArrow(pt0: Vec3, pt1: Vec3, color: ColorRepresentation = defaultColor, duration: number = 0, depthTest: boolean = true, wireframe: boolean = false) {
|
|
168
256
|
if (!Gizmos.enabled) return;
|
|
169
257
|
const obj = Internal.getArrowHead(duration);
|
|
@@ -209,13 +297,6 @@ export class Gizmos {
|
|
|
209
297
|
mesh.material["depthTest"] = options.depthTest ?? true;
|
|
210
298
|
mesh.material["wireframe"] = true;
|
|
211
299
|
}
|
|
212
|
-
|
|
213
|
-
/** Set visibility of all currently rendered gizmos */
|
|
214
|
-
static setVisible(visible: boolean) {
|
|
215
|
-
for (const obj of Internal.timedObjectsBuffer) {
|
|
216
|
-
obj.visible = visible;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
300
|
}
|
|
220
301
|
|
|
221
302
|
const box: BoxGeometry = new BoxGeometry(1, 1, 1);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { EffectComposer } from "postprocessing";
|
|
2
2
|
import { Camera, Mesh, Object3D, Texture, WebGLRenderer, WebGLRenderTarget } from "three";
|
|
3
|
+
import type { EffectComposer as ThreeEffectComposer } from "three/examples/jsm/postprocessing/EffectComposer";
|
|
3
4
|
|
|
4
5
|
import { findResourceUsers } from "./engine_assetdatabase.js";
|
|
5
6
|
|
|
@@ -27,9 +28,9 @@ export class RenderTexture extends WebGLRenderTarget {
|
|
|
27
28
|
* @param camera The camera to render from
|
|
28
29
|
* @param renderer The renderer or effectcomposer to use
|
|
29
30
|
*/
|
|
30
|
-
render(scene: Object3D, camera: Camera, renderer: WebGLRenderer | EffectComposer) {
|
|
31
|
+
render(scene: Object3D, camera: Camera, renderer: WebGLRenderer | EffectComposer | ThreeEffectComposer) {
|
|
31
32
|
|
|
32
|
-
const composer = renderer as EffectComposer;
|
|
33
|
+
const composer = renderer as (EffectComposer | ThreeEffectComposer);
|
|
33
34
|
|
|
34
35
|
if ("addPass" in composer) {
|
|
35
36
|
if (!this["_unsupported_effectcomposer_warning"]) {
|
|
@@ -87,8 +87,8 @@ vec3 _agx(vec3 val) {
|
|
|
87
87
|
0.0784335999999992, 0.878468636469772, 0.0784336,
|
|
88
88
|
0.0792237451477643, 0.0791661274605434, 0.879142973793104);
|
|
89
89
|
|
|
90
|
-
const float min_ev = -12.
|
|
91
|
-
const float max_ev = 4.
|
|
90
|
+
const float min_ev = -12.47393;
|
|
91
|
+
const float max_ev = 4.026069;
|
|
92
92
|
|
|
93
93
|
// val = pow(val, vec3(2.2));
|
|
94
94
|
|