@needle-tools/engine 3.2.15-alpha → 3.4.0-alpha
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 +23 -0
- package/dist/needle-engine.js +44005 -36382
- package/dist/needle-engine.min.js +706 -513
- package/dist/needle-engine.umd.cjs +685 -492
- package/lib/engine/codegen/register_types.js +54 -4
- package/lib/engine/codegen/register_types.js.map +1 -1
- package/lib/engine/engine_addressables.d.ts +3 -3
- package/lib/engine/engine_addressables.js +30 -9
- package/lib/engine/engine_addressables.js.map +1 -1
- package/lib/engine/engine_element.js +1 -1
- package/lib/engine/engine_element.js.map +1 -1
- package/lib/engine/engine_gameobject.d.ts +2 -1
- package/lib/engine/engine_gameobject.js +19 -0
- package/lib/engine/engine_gameobject.js.map +1 -1
- package/lib/engine/engine_input.js +10 -0
- package/lib/engine/engine_input.js.map +1 -1
- package/lib/engine/engine_math.d.ts +4 -0
- package/lib/engine/engine_math.js +6 -0
- package/lib/engine/engine_math.js.map +1 -1
- package/lib/engine/engine_three_utils.js +2 -2
- package/lib/engine/engine_three_utils.js.map +1 -1
- package/lib/engine-components/Animation.js +4 -0
- package/lib/engine-components/Animation.js.map +1 -1
- package/lib/engine-components/AnimatorController.js +7 -2
- package/lib/engine-components/AnimatorController.js.map +1 -1
- package/lib/engine-components/OrbitControls.js +13 -4
- package/lib/engine-components/OrbitControls.js.map +1 -1
- package/lib/engine-components/TransformGizmo.d.ts +8 -4
- package/lib/engine-components/TransformGizmo.js +62 -63
- package/lib/engine-components/TransformGizmo.js.map +1 -1
- package/lib/engine-components/codegen/components.d.ts +27 -2
- package/lib/engine-components/codegen/components.js +27 -2
- package/lib/engine-components/codegen/components.js.map +1 -1
- package/lib/engine-components/export/usdz/Extension.d.ts +4 -4
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.d.ts +86 -0
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.js +830 -0
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.js.map +1 -0
- package/lib/engine-components/export/usdz/USDZExporter.d.ts +6 -3
- package/lib/engine-components/export/usdz/USDZExporter.js +34 -11
- package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
- package/lib/engine-components/export/usdz/extensions/Animation.d.ts +15 -15
- package/lib/engine-components/export/usdz/extensions/Animation.js +24 -29
- package/lib/engine-components/export/usdz/extensions/Animation.js.map +1 -1
- package/lib/engine-components/export/usdz/extensions/DocumentExtension.d.ts +5 -0
- package/lib/engine-components/export/usdz/extensions/DocumentExtension.js +7 -0
- package/lib/engine-components/export/usdz/extensions/DocumentExtension.js.map +1 -0
- package/lib/engine-components/export/usdz/extensions/USDZText.d.ts +47 -0
- package/lib/engine-components/export/usdz/extensions/USDZText.js +114 -0
- package/lib/engine-components/export/usdz/extensions/USDZText.js.map +1 -0
- package/lib/engine-components/export/usdz/extensions/behavior/Actions.d.ts +30 -0
- package/lib/engine-components/export/usdz/extensions/behavior/Actions.js +89 -0
- package/lib/engine-components/export/usdz/extensions/behavior/Actions.js.map +1 -0
- package/lib/engine-components/export/usdz/extensions/behavior/Behaviour.d.ts +23 -0
- package/lib/engine-components/export/usdz/extensions/behavior/Behaviour.js +114 -0
- package/lib/engine-components/export/usdz/extensions/behavior/Behaviour.js.map +1 -0
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.d.ts +96 -0
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js +421 -0
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js.map +1 -0
- package/lib/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.d.ts +111 -0
- package/lib/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.js +409 -0
- package/lib/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.js.map +1 -0
- package/lib/engine-components/postprocessing/PostProcessingHandler.js.map +1 -1
- package/lib/engine-components/ui/BaseUIComponent.d.ts +2 -0
- package/lib/engine-components/ui/BaseUIComponent.js +6 -0
- package/lib/engine-components/ui/BaseUIComponent.js.map +1 -1
- package/lib/engine-components/ui/Button.js +9 -5
- package/lib/engine-components/ui/Button.js.map +1 -1
- package/lib/engine-components/ui/Canvas.d.ts +23 -6
- package/lib/engine-components/ui/Canvas.js +167 -34
- package/lib/engine-components/ui/Canvas.js.map +1 -1
- package/lib/engine-components/ui/EventSystem.d.ts +6 -0
- package/lib/engine-components/ui/EventSystem.js +4 -4
- package/lib/engine-components/ui/EventSystem.js.map +1 -1
- package/lib/engine-components/ui/Graphic.d.ts +5 -2
- package/lib/engine-components/ui/Graphic.js +38 -7
- package/lib/engine-components/ui/Graphic.js.map +1 -1
- package/lib/engine-components/ui/Image.d.ts +1 -0
- package/lib/engine-components/ui/Image.js +14 -5
- package/lib/engine-components/ui/Image.js.map +1 -1
- package/lib/engine-components/ui/InputField.d.ts +1 -0
- package/lib/engine-components/ui/InputField.js +8 -0
- package/lib/engine-components/ui/InputField.js.map +1 -1
- package/lib/engine-components/ui/Interfaces.d.ts +19 -0
- package/lib/engine-components/ui/Interfaces.js +11 -0
- package/lib/engine-components/ui/Interfaces.js.map +1 -1
- package/lib/engine-components/ui/Layout.d.ts +65 -3
- package/lib/engine-components/ui/Layout.js +304 -3
- package/lib/engine-components/ui/Layout.js.map +1 -1
- package/lib/engine-components/ui/Outline.d.ts +7 -0
- package/lib/engine-components/ui/Outline.js +21 -0
- package/lib/engine-components/ui/Outline.js.map +1 -0
- package/lib/engine-components/ui/RectTransform.d.ts +32 -13
- package/lib/engine-components/ui/RectTransform.js +216 -56
- package/lib/engine-components/ui/RectTransform.js.map +1 -1
- package/lib/engine-components/ui/Text.d.ts +13 -10
- package/lib/engine-components/ui/Text.js +177 -246
- package/lib/engine-components/ui/Text.js.map +1 -1
- package/lib/engine-components/utils/LookAt.d.ts +13 -0
- package/lib/engine-components/utils/LookAt.js +66 -0
- package/lib/engine-components/utils/LookAt.js.map +1 -0
- package/lib/engine-components/webxr/WebXRImageTracking.d.ts +12 -3
- package/lib/engine-components/webxr/WebXRImageTracking.js +156 -24
- package/lib/engine-components/webxr/WebXRImageTracking.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/plugins/vite/reload.js +13 -2
- package/src/engine/codegen/register_types.js +56 -6
- package/src/engine/engine_addressables.ts +28 -10
- package/src/engine/engine_element.ts +1 -1
- package/src/engine/engine_gameobject.ts +19 -1
- package/src/engine/engine_input.ts +11 -0
- package/src/engine/engine_math.ts +10 -0
- package/src/engine/engine_three_utils.ts +2 -2
- package/src/engine-components/Animation.ts +4 -0
- package/src/engine-components/AnimatorController.ts +7 -1
- package/src/engine-components/OrbitControls.ts +14 -6
- package/src/engine-components/TransformGizmo.ts +64 -70
- package/src/engine-components/codegen/components.ts +27 -2
- package/src/engine-components/export/usdz/Extension.ts +4 -5
- package/src/engine-components/export/usdz/ThreeUSDZExporter.ts +1280 -0
- package/src/engine-components/export/usdz/USDZExporter.ts +39 -17
- package/src/engine-components/export/usdz/extensions/Animation.ts +37 -45
- package/src/engine-components/export/usdz/extensions/DocumentExtension.ts +10 -0
- package/src/engine-components/export/usdz/extensions/USDZText.ts +142 -0
- package/src/engine-components/export/usdz/extensions/behavior/Actions.ts +99 -0
- package/src/engine-components/export/usdz/extensions/behavior/Behaviour.ts +181 -0
- package/src/engine-components/export/usdz/extensions/behavior/BehaviourComponents.ts +503 -0
- package/src/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.ts +459 -0
- package/src/engine-components/postprocessing/PostProcessingHandler.ts +1 -1
- package/src/engine-components/ui/BaseUIComponent.ts +7 -1
- package/src/engine-components/ui/Button.ts +14 -9
- package/src/engine-components/ui/Canvas.ts +178 -39
- package/src/engine-components/ui/EventSystem.ts +16 -9
- package/src/engine-components/ui/Graphic.ts +46 -8
- package/src/engine-components/ui/Image.ts +13 -4
- package/src/engine-components/ui/InputField.ts +9 -1
- package/src/engine-components/ui/Interfaces.ts +39 -3
- package/src/engine-components/ui/Layout.ts +303 -4
- package/src/engine-components/ui/Outline.ts +13 -0
- package/src/engine-components/ui/RectTransform.ts +236 -68
- package/src/engine-components/ui/Text.ts +284 -265
- package/src/engine-components/utils/LookAt.ts +74 -0
- package/src/engine-components/webxr/WebXRImageTracking.ts +179 -31
- package/lib/engine-components/export/usdz/types.d.ts +0 -34
- package/lib/engine-components/export/usdz/types.js +0 -2
- package/lib/engine-components/export/usdz/types.js.map +0 -1
- package/lib/engine-components/ui/Keyboard.d.ts +0 -31
- package/lib/engine-components/ui/Keyboard.js +0 -178
- package/lib/engine-components/ui/Keyboard.js.map +0 -1
- package/src/engine-components/export/usdz/types.ts +0 -39
- package/src/engine-components/ui/Keyboard.ts +0 -204
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
import * as ThreeMeshUI from 'three-mesh-ui'
|
|
2
|
-
import * as THREE from 'three'
|
|
3
|
-
import { BaseUIComponent, includesDir } from './BaseUIComponent';
|
|
4
|
-
import { Text } from './Text';
|
|
5
|
-
import { getWorldScale } from '../../engine/engine_three_utils';
|
|
6
|
-
import { RectTransform } from './RectTransform';
|
|
7
|
-
import { GameObject } from '../Component';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
enum KeymapOption {
|
|
11
|
-
fr,
|
|
12
|
-
ru,
|
|
13
|
-
de,
|
|
14
|
-
es,
|
|
15
|
-
el,
|
|
16
|
-
nord,
|
|
17
|
-
eng
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// see https://github.com/felixmariotto/three-mesh-ui/blob/master/examples/keyboard.js
|
|
22
|
-
export class Keyboard extends BaseUIComponent {
|
|
23
|
-
|
|
24
|
-
font?: string;
|
|
25
|
-
text?: Text;
|
|
26
|
-
keymap?: KeymapOption;
|
|
27
|
-
padding?: number;
|
|
28
|
-
margin?: number;
|
|
29
|
-
fontSize?: number;
|
|
30
|
-
borderRadius?: number;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
private colors = {
|
|
34
|
-
keyboardBack: 0x858585,
|
|
35
|
-
panelBack: 0x262626,
|
|
36
|
-
button: 0x363636,
|
|
37
|
-
hovered: 0x1c1c1c,
|
|
38
|
-
selected: 0x109c5d,
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
awake() {
|
|
43
|
-
super.awake();
|
|
44
|
-
const langKey = KeymapOption[this.keymap || KeymapOption.eng];
|
|
45
|
-
this.makeKeyboard(langKey);
|
|
46
|
-
}
|
|
47
|
-
onEnable(): void {
|
|
48
|
-
this.addShadowComponent(this.keyboard);
|
|
49
|
-
}
|
|
50
|
-
onDisable(): void {
|
|
51
|
-
this.removeShadowComponent();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
private keyboard: ThreeMeshUI.Keyboard | null = null!;
|
|
55
|
-
private _lastKeyPressed: any;
|
|
56
|
-
private _lastKeyPressedStartTime: number = 0;
|
|
57
|
-
private _lastKeyPressedTime: number = 0;
|
|
58
|
-
|
|
59
|
-
private makeKeyboard(language?: string) {
|
|
60
|
-
|
|
61
|
-
if (!language && !navigator.language) {
|
|
62
|
-
language = "en";
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const fontName = this.font ? this.font : "arial";
|
|
66
|
-
|
|
67
|
-
const rt = GameObject.getComponent(this.gameObject, RectTransform);
|
|
68
|
-
if(!rt){
|
|
69
|
-
console.error("Missing rect transform, please add this component inside a canvas");
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
const opts = {
|
|
73
|
-
...rt.getBasicOptions(),
|
|
74
|
-
margin: this.margin || 0,
|
|
75
|
-
padding: this.padding || 0,
|
|
76
|
-
language: language,
|
|
77
|
-
fontFamily: includesDir + "/" + fontName + "-msdf.json",
|
|
78
|
-
fontTexture: includesDir + "/" + fontName + ".png",
|
|
79
|
-
fontSize: this.fontSize || 6, // fontSize will propagate to the keys blocks
|
|
80
|
-
backgroundColor: new THREE.Color(this.colors.keyboardBack),
|
|
81
|
-
backspaceTexture: includesDir + '/backspace.png',
|
|
82
|
-
shiftTexture: includesDir + '/shift.png',
|
|
83
|
-
enterTexture: includesDir + '/enter.png',
|
|
84
|
-
borderRadius: this.borderRadius || 0,
|
|
85
|
-
autoLayout: false,
|
|
86
|
-
|
|
87
|
-
};
|
|
88
|
-
// const ws = getWorldScale(this.gameObject);
|
|
89
|
-
const scale = this.gameObject.scale;
|
|
90
|
-
opts.width *= this.gameObject.scale.x;
|
|
91
|
-
opts.height *= this.gameObject.scale.y;
|
|
92
|
-
opts.fontSize *= Math.max(scale.x, scale.y);
|
|
93
|
-
this.keyboard = new ThreeMeshUI.Keyboard(opts);
|
|
94
|
-
|
|
95
|
-
// const scale = this.gameObject.scale;
|
|
96
|
-
// const max = Math.max(scale.x, scale.y, scale.z);
|
|
97
|
-
this.gameObject.scale.set(1, 1, 1);
|
|
98
|
-
|
|
99
|
-
//@ts-ignore
|
|
100
|
-
this.keyboard.keys.forEach((key) => {
|
|
101
|
-
|
|
102
|
-
key.setupState({
|
|
103
|
-
state: 'normal',
|
|
104
|
-
attributes: {
|
|
105
|
-
offset: 0.003,
|
|
106
|
-
backgroundColor: new THREE.Color(this.colors.button),
|
|
107
|
-
backgroundOpacity: 1
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
key.setState("normal");
|
|
111
|
-
|
|
112
|
-
key.setupState({
|
|
113
|
-
state: 'hovered',
|
|
114
|
-
attributes: {
|
|
115
|
-
offset: 0.3,
|
|
116
|
-
backgroundColor: new THREE.Color(this.colors.hovered),
|
|
117
|
-
backgroundOpacity: 1
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
key.setupState({
|
|
122
|
-
state: 'pressed',
|
|
123
|
-
attributes: {
|
|
124
|
-
offset: 0.1,
|
|
125
|
-
backgroundColor: new THREE.Color(this.colors.selected),
|
|
126
|
-
backgroundOpacity: 1
|
|
127
|
-
},
|
|
128
|
-
// triggered when the user clicked on a keyboard's key
|
|
129
|
-
onSet: () => {
|
|
130
|
-
const input = key.info.input;
|
|
131
|
-
const cmd = key.info.command;
|
|
132
|
-
if (this._lastKeyPressed !== input) {
|
|
133
|
-
this._lastKeyPressedStartTime = this.context.time.time;
|
|
134
|
-
}
|
|
135
|
-
else if (this.context.time.time - this._lastKeyPressedTime > .05) {
|
|
136
|
-
// there was probably a key up inbetween
|
|
137
|
-
this._lastKeyPressedStartTime = this.context.time.time;
|
|
138
|
-
}
|
|
139
|
-
else if (this.context.time.time - this._lastKeyPressedStartTime < .5
|
|
140
|
-
|| cmd == "switch"
|
|
141
|
-
|| cmd == "shift"
|
|
142
|
-
|| cmd == "switch-set"
|
|
143
|
-
) {
|
|
144
|
-
this._lastKeyPressedTime = this.context.time.time;
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
this._lastKeyPressedTime = this.context.time.time;
|
|
148
|
-
this._lastKeyPressed = input;
|
|
149
|
-
// if the key have a command (eg: 'backspace', 'switch', 'enter'...)
|
|
150
|
-
// special actions are taken
|
|
151
|
-
if (cmd) {
|
|
152
|
-
switch (cmd) {
|
|
153
|
-
// switch between panels
|
|
154
|
-
case 'switch':
|
|
155
|
-
//@ts-ignore
|
|
156
|
-
this.keyboard.setNextPanel();
|
|
157
|
-
break;
|
|
158
|
-
|
|
159
|
-
// switch between panel charsets (eg: russian/english)
|
|
160
|
-
case 'switch-set':
|
|
161
|
-
//@ts-ignore
|
|
162
|
-
this.keyboard.setNextCharset();
|
|
163
|
-
break;
|
|
164
|
-
|
|
165
|
-
case 'enter':
|
|
166
|
-
this.tryAppend('\n');
|
|
167
|
-
break;
|
|
168
|
-
|
|
169
|
-
case 'space':
|
|
170
|
-
this.tryAppend(' ');
|
|
171
|
-
break;
|
|
172
|
-
|
|
173
|
-
case 'backspace':
|
|
174
|
-
//@ts-ignore
|
|
175
|
-
if (!this.text?.text?.length) break
|
|
176
|
-
if (this.text?.text)
|
|
177
|
-
this.text.text = this.text.text.substring(0, this.text.text.length - 1) || ""
|
|
178
|
-
break;
|
|
179
|
-
|
|
180
|
-
case 'shift':
|
|
181
|
-
//@ts-ignore
|
|
182
|
-
this.keyboard.toggleCase();
|
|
183
|
-
break;
|
|
184
|
-
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
// print a glyph, if any
|
|
188
|
-
} else if (key.info.input !== undefined) {
|
|
189
|
-
this.tryAppend(key.info.input);
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
});
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
private tryAppend(char: string) {
|
|
199
|
-
if (this.text) {
|
|
200
|
-
this.text.text += char;
|
|
201
|
-
this.markDirty();
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|