@needle-tools/engine 2.63.1-pre → 2.63.2-pre

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.
@@ -0,0 +1,4 @@
1
+ const e = {};
2
+ export {
3
+ e as default
4
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@needle-tools/engine",
3
- "version": "2.63.1-pre",
3
+ "version": "2.63.2-pre",
4
4
  "description": "Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development, and can be deployed anywhere. It is flexible, extensible, and collaboration and XR come naturally.",
5
5
  "main": "dist/needle-engine.umd.cjs",
6
6
  "module": "dist/needle-engine.js",
@@ -25,7 +25,8 @@
25
25
  "LICENSE.md",
26
26
  "src",
27
27
  "dist",
28
- "lib"
28
+ "lib",
29
+ "license-2447137e.js"
29
30
  ],
30
31
  "keywords": [
31
32
  "needle",
@@ -0,0 +1 @@
1
+ export const hasLicense = false;
@@ -109,6 +109,7 @@ function createLicenseElement() {
109
109
  return licenseElement;
110
110
  }
111
111
 
112
+ // TODO: would be better to put this into a web element and use shadow dom
112
113
  function createLicenseStyle() {
113
114
  const licenseStyle = document.createElement("style");
114
115
  const selector = "." + licenseElementClass;
@@ -120,10 +121,17 @@ function createLicenseStyle() {
120
121
  font-weight: 300;
121
122
  }
122
123
 
124
+ ${selector}, ${selector} > * {
125
+ display: inline-block !important;
126
+ visibility: visible !important;
127
+ background: none !important;
128
+ border: none !important;
129
+ text-decoration: none !important;
130
+ }
131
+
123
132
  ${selector} a {
124
- color: black;
125
- text-decoration: none;
126
- font-weight: 500;
133
+ color: black !important;
134
+ font-weight: 500 !important;
127
135
  }
128
136
 
129
137
  @keyframes append-animate {
@@ -173,21 +181,18 @@ function createLicenseStyle() {
173
181
  animation-easing: ease-in-out;
174
182
  }
175
183
 
176
- ${selector} .text, ${selector} a {
177
- color: rgb(255, 0, 0);
178
- mix-blend-mode: difference;
179
- }
180
-
181
184
  ${selector} .logo {
182
- border-radius: 50%;
183
- background-color: transparent;
184
- padding: 5px;
185
- transition: all 0.1s ease-in-out;
185
+ position: relative !important;
186
+ display: inline-block !important;
187
+ border-radius: 50% !important;
188
+ background-color: transparent !important;
189
+ padding: 5px !important;
190
+ transition: all 0.1s ease-in-out !important;
186
191
  }
187
192
 
188
193
  ${selector} .logo:hover {
189
- transform: scale(1.3);
190
- cursor: pointer;
194
+ transform: scale(1.3) !important;
195
+ cursor: pointer !important;
191
196
  }
192
197
  `
193
198
  return licenseStyle;
@@ -1,12 +1,14 @@
1
1
 
2
2
  import * as THREE from "three";
3
3
  import { syncDestroy } from "../engine/engine_networking_instantiate";
4
+ import { getParam } from "../engine/engine_utils";
4
5
  import { BoxHelperComponent } from "./BoxHelperComponent";
5
6
  import { Behaviour, GameObject } from "./Component";
6
7
  import { UsageMarker } from "./Interactable";
7
8
 
9
+ const debug = getParam("debugdeletable");
8
10
 
9
- export class DeleteBox extends BoxHelperComponent {}
11
+ export class DeleteBox extends BoxHelperComponent { }
10
12
 
11
13
 
12
14
  export class Deletable extends Behaviour {
@@ -21,13 +23,13 @@ export class Deletable extends Behaviour {
21
23
  for (const box of this.deleteBoxes) {
22
24
  const obj = this.gameObject as unknown as THREE.Mesh;
23
25
  const res = box.isInBox(obj);
24
- // console.log(res);
25
26
  if (res === true) {
26
27
  const marker = GameObject.getComponentInParent(this.gameObject, UsageMarker);
27
28
  if (!marker) {
28
- // console.log("DESTROY");
29
+ if (debug) console.log("DESTROY", this.gameObject);
29
30
  syncDestroy(this.gameObject, this.context.connection);
30
31
  }
32
+ else if (debug) console.warn("Can not delete object with usage marker", this.guid, marker)
31
33
  }
32
34
  }
33
35
  }
@@ -153,11 +153,8 @@ export class DragControls extends Interactable implements IPointerDownHandler, I
153
153
  this.onUpdateDrag();
154
154
  }
155
155
 
156
-
157
- if (this._isDragging) {
158
- if (this._dragHelper?.hasSelected === false) {
159
- this.onDragEnd(null);
160
- }
156
+ if (this._dragHelper?.hasSelected === false || (this._activePointerId !== undefined && this.context.input.getPointerPressed(this._activePointerId) === false)) {
157
+ this.onDragEnd(null);
161
158
  }
162
159
  }
163
160
 
@@ -165,6 +162,7 @@ export class DragControls extends Interactable implements IPointerDownHandler, I
165
162
  private _marker: UsageMarker | null = null;
166
163
  private _dragDelta!: THREE.Vector2;
167
164
  private _didDrag: boolean = false;
165
+ private _activePointerId?: number;
168
166
 
169
167
  private onDragStart(evt: PointerEventData) {
170
168
  if (!this._dragHelper) {
@@ -191,14 +189,22 @@ export class DragControls extends Interactable implements IPointerDownHandler, I
191
189
  listener(this, args);
192
190
  }
193
191
 
192
+ this._activePointerId = evt.pointerId;
193
+
194
194
  if (!args.attached) return;
195
195
  if (args.attached !== object) {
196
- // if duplicatable changes the object being dragged
197
- // should it also change the active drag controls (e.g. if it has a own one)
196
+ // // if duplicatable changes the object being dragged
197
+ // // should it also change the active drag controls (e.g. if it has a own one)
198
198
  // const drag = GameObject.getComponentInParent(args.attached, DragControls);
199
- // if(drag !== this){
200
- // console.log(args.attached, object);
201
- // drag?.onDragStart(evt);
199
+ // if (drag && drag !== this) {
200
+ // // incredibly ugly code to pass the drag controls event to another drag controls instance
201
+ // // This is necessary since we dont call the onPointerUp events anymore for all objects
202
+ // // that have previously received the onPointerDown event.
203
+ // // NOTE: added the EventSystem.raisedPointerDownEvents array again because of this uglyness here. The code was originally removed in 757fc5e5bafd02aa13d6cd35dd5e8729c841465a and now we're adding it in 8ce886d8344d1abd5ebb89ae3e1fb8d6d47293da
204
+ // this.onDragEnd(null);
205
+ // drag.onPointerDown(evt);
206
+ // evt.object = args.attached;
207
+ // drag.onDragStart(evt);
202
208
  // return;
203
209
  // }
204
210
  }
@@ -257,9 +263,9 @@ export class DragControls extends Interactable implements IPointerDownHandler, I
257
263
  sync.fastMode = false;
258
264
  // sync?.requestOwnership();
259
265
  }
260
- if (this._marker) {
261
- this._marker.destroy();
262
- }
266
+ }
267
+ if (this._marker) {
268
+ this._marker.destroy();
263
269
  }
264
270
  // raise event
265
271
  for (const listener of this.selectEndEventListener) {
@@ -9,6 +9,7 @@ import * as Tracks from "./TimelineTracks";
9
9
  import { deepClone, getParam } from '../../engine/engine_utils';
10
10
  import { GuidsMap } from '../../engine/engine_types';
11
11
  import { Object3D } from 'three';
12
+ import { isLocalNetwork } from '../../engine/engine_networking_utils';
12
13
 
13
14
  const debug = getParam("debugtimeline");
14
15
 
@@ -72,7 +73,13 @@ export class PlayableDirector extends Behaviour {
72
73
  get isPlaying(): boolean { return this._isPlaying; }
73
74
  get isPaused(): boolean { return this._isPaused; }
74
75
  get time(): number { return this._time; }
75
- set time(value: number) { this._time = value; }
76
+ set time(value: number) {
77
+ if (typeof value === "number" && !Number.isNaN(value))
78
+ this._time = value;
79
+ else if (debug || isLocalNetwork()) {
80
+ console.error("INVALID TIMELINE.TIME VALUE", value, this.name)
81
+ };
82
+ }
76
83
  get duration(): number { return this._duration; }
77
84
  set duration(value: number) { this._duration = value; }
78
85
  get weight(): number { return this._weight; };
@@ -264,11 +264,11 @@ export class EventSystem extends Behaviour {
264
264
  else return;
265
265
 
266
266
  if (this.lastPointerEvent.isUp) {
267
- // for (const obj of this.raisedPointerDownEvents) {
268
- // if (obj.onPointerUp) {
269
- // obj.onPointerUp(this.lastPointerEvent);
270
- // }
271
- // }
267
+ for (const obj of this.raisedPointerDownEvents) {
268
+ if (obj.onPointerUp) {
269
+ obj.onPointerUp(this.lastPointerEvent);
270
+ }
271
+ }
272
272
  this.raisedPointerDownEvents.length = 0;
273
273
  this.raisedPointerDownObjects.length = 0;
274
274
  }
@@ -426,7 +426,8 @@ export class EventSystem extends Behaviour {
426
426
  if (args.isDown) {
427
427
  if (comp.onPointerDown && !this.raisedPointerDownEvents.includes(comp)) {
428
428
  comp.onPointerDown(args);
429
- // need to save this to also send pointer up event
429
+ // need to save this to also send pointer up event to objects we sent pointer down to previously
430
+ // for example Duplicatable+DragControls currently expects this behaviour
430
431
  this.raisedPointerDownEvents.push(comp);
431
432
  this.raisedPointerDownObjects.push(originalObject);
432
433
  }
@@ -434,6 +435,14 @@ export class EventSystem extends Behaviour {
434
435
 
435
436
  if (args.isUp) {
436
437
  if (comp.onPointerUp) {
438
+ // Remove the pointer up event handling here to not send it twice
439
+ // the array is just used for when the "UP" event doesnt hit the same object as the "DOWN" event
440
+ // For example if the object was cloned by the Duplicatable
441
+ // The original component that received the down event SHOULD also receive the up event tho
442
+ const index = this.raisedPointerDownEvents.indexOf(comp);
443
+ if (index !== -1) {
444
+ this.raisedPointerDownEvents.splice(index, 1);
445
+ }
437
446
  comp.onPointerUp(args);
438
447
  }
439
448
  }