mage-engine 3.25.6 → 3.25.7

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 (2) hide show
  1. package/dist/mage.js +988 -28
  2. package/package.json +1 -1
package/dist/mage.js CHANGED
@@ -56520,13 +56520,22 @@ let Physics = /*#__PURE__*/function (_EventDispatcher) {
56520
56520
  value: function add(element, options = {}) {
56521
56521
  if (Config$1.physics().enabled) {
56522
56522
  const {
56523
- colliderType = COLLIDER_TYPES$1.BOX
56523
+ colliderType = COLLIDER_TYPES$1.BOX,
56524
+ colliderWidth,
56525
+ colliderHeight,
56526
+ colliderLength,
56527
+ colliderRadius,
56528
+ ...rest
56524
56529
  } = options;
56525
56530
  const uuid = element.uuid();
56526
56531
  const description = {
56527
56532
  ...mapColliderTypeToDescription(colliderType)(element),
56528
- ...options
56533
+ ...rest
56529
56534
  };
56535
+ if (colliderWidth != null) description.width = colliderWidth;
56536
+ if (colliderHeight != null) description.height = colliderHeight;
56537
+ if (colliderLength != null) description.length = colliderLength;
56538
+ if (colliderRadius != null) description.radius = colliderRadius;
56530
56539
  this.storeElement(element, options);
56531
56540
  this.worker.postMessage({
56532
56541
  event: mapColliderTypeToAddEvent(description.collider),
@@ -58125,10 +58134,11 @@ var Physics$1 = new Physics();let Orbit = /*#__PURE__*/function (_EventDispatche
58125
58134
  _this.gizmo = new Gizmo();
58126
58135
  _this.plane = new TransformControlsPlane();
58127
58136
 
58128
- // Set gizmo and plane to layer 1 ONLY so mirrors don't render them
58129
- // Main camera must enable layer 1 to see these
58130
- _this.gizmo.layers.set(1);
58131
- _this.plane.layers.set(1);
58137
+ // Set gizmo and plane to layer 2 ONLY so they render in a dedicated pass
58138
+ // on top of everything (sky, post-processing, etc.)
58139
+ // Layer 1 = editor helpers (togglable), Layer 2 = gizmo (always visible)
58140
+ _this.gizmo.layers.set(2);
58141
+ _this.plane.layers.set(2);
58132
58142
 
58133
58143
  // Helper function to set depth properties on materials
58134
58144
  const setMaterialDepth = material => {
@@ -58142,15 +58152,15 @@ var Physics$1 = new Physics();let Orbit = /*#__PURE__*/function (_EventDispatche
58142
58152
  });
58143
58153
  };
58144
58154
 
58145
- // Also set layer 1 on all children recursively
58146
- // Set high renderOrder and disable depthTest so gizmos render on top of sky/water
58155
+ // Also set layer 2 on all children recursively
58156
+ // Disable depthTest so gizmos render on top of everything
58147
58157
  _this.gizmo.traverse(child => {
58148
- child.layers.set(1);
58158
+ child.layers.set(2);
58149
58159
  child.renderOrder = 999;
58150
58160
  setMaterialDepth(child.material);
58151
58161
  });
58152
58162
  _this.plane.traverse(child => {
58153
- child.layers.set(1);
58163
+ child.layers.set(2);
58154
58164
  child.renderOrder = 999;
58155
58165
  setMaterialDepth(child.material);
58156
58166
  });
@@ -58191,8 +58201,8 @@ var Physics$1 = new Physics();let Orbit = /*#__PURE__*/function (_EventDispatche
58191
58201
  _this.setAndDispatch("showY", true);
58192
58202
  _this.setAndDispatch("showZ", true);
58193
58203
  _this.ray = new Raycaster();
58194
- // Enable layer 1 so raycaster can pick gizmo objects (which are on layer 1)
58195
- _this.ray.layers.enable(1);
58204
+ // Enable layer 2 so raycaster can pick gizmo objects (which are on layer 2)
58205
+ _this.ray.layers.enable(2);
58196
58206
  _this._tempVector = new Vector3$1();
58197
58207
  _this._tempVector2 = new Vector3$1();
58198
58208
  _this._tempQuaternion = new Quaternion();
@@ -60103,10 +60113,12 @@ var Controls$1 = new Controls();let Scene = /*#__PURE__*/function () {
60103
60113
  key: "createCamera",
60104
60114
  value: function createCamera(camera) {
60105
60115
  this.camera = camera;
60106
- // Enable layer 1 so camera can see editor-only objects (helpers, grid, gizmos)
60116
+ // Enable layer 1 so camera can see editor-only objects (helpers, grid)
60117
+ // Enable layer 2 so camera can see gizmos (rendered in separate pass)
60107
60118
  // Mirror cameras only use layer 0, so they won't render these
60108
60119
  if (this.camera && this.camera.getBody()) {
60109
60120
  this.camera.getBody().layers.enable(1);
60121
+ this.camera.getBody().layers.enable(2);
60110
60122
  }
60111
60123
  }
60112
60124
  }, {
@@ -60204,6 +60216,53 @@ var Controls$1 = new Controls();let Scene = /*#__PURE__*/function () {
60204
60216
  this.renderer.setRenderTarget(null);
60205
60217
  this.renderer.render(this.scene, this.camera.getBody());
60206
60218
  }
60219
+
60220
+ // Render gizmo layer (layer 2) on top of everything.
60221
+ // Called after main render or post-processing to ensure gizmos are always visible
60222
+ // regardless of sky, post-processing, or sortObjects setting.
60223
+ }, {
60224
+ key: "renderGizmoLayer",
60225
+ value: function renderGizmoLayer() {
60226
+ if (!this.renderer || !this.camera) return;
60227
+ const cameraBody = this.camera.getBody();
60228
+
60229
+ // Save current camera layer mask
60230
+ const savedLayers = cameraBody.layers.mask;
60231
+
60232
+ // Set camera to only see layer 2 (gizmo layer)
60233
+ cameraBody.layers.set(2);
60234
+
60235
+ // Ensure we render to screen (not a post-processing buffer)
60236
+ this.renderer.setRenderTarget(null);
60237
+ // Clear only depth so gizmo renders on top of the already-drawn frame
60238
+ this.renderer.autoClear = false;
60239
+ this.renderer.clearDepth();
60240
+ this.renderer.render(this.scene, cameraBody);
60241
+ this.renderer.autoClear = true;
60242
+
60243
+ // Restore camera layers
60244
+ cameraBody.layers.mask = savedLayers;
60245
+ }
60246
+
60247
+ // Toggle editor helpers visibility (layer 1: grid, light helpers, camera helpers)
60248
+ // Does NOT affect gizmos (layer 2) which are always visible
60249
+ }, {
60250
+ key: "setHelpersVisible",
60251
+ value: function setHelpersVisible(visible) {
60252
+ if (!this.camera || !this.camera.getBody()) return;
60253
+ const cameraBody = this.camera.getBody();
60254
+ if (visible) {
60255
+ cameraBody.layers.enable(1);
60256
+ } else {
60257
+ cameraBody.layers.disable(1);
60258
+ }
60259
+ this.helpersVisible = visible;
60260
+ }
60261
+ }, {
60262
+ key: "getHelpersVisible",
60263
+ value: function getHelpersVisible() {
60264
+ return this.helpersVisible !== false;
60265
+ }
60207
60266
  }, {
60208
60267
  key: "setFog",
60209
60268
  value: function setFog(color, density) {
@@ -61301,7 +61360,7 @@ function applyMiddleware() {
61301
61360
 
61302
61361
  var thunk = createThunkMiddleware();
61303
61362
  thunk.withExtraArgument = createThunkMiddleware;var name = "mage-engine";
61304
- var version$1 = "3.25.6";
61363
+ var version$1 = "3.25.7";
61305
61364
  var description = "A WebGL Javascript Game Engine, built on top of THREE.js and many other libraries.";
61306
61365
  var main = "dist/mage.js";
61307
61366
  var author$1 = {
@@ -64742,6 +64801,26 @@ let Element$1 = /*#__PURE__*/function (_Entity) {
64742
64801
  setUpLightsAndShadows(this.getBody());
64743
64802
  }
64744
64803
  }
64804
+ }, {
64805
+ key: "getComputedColliderSize",
64806
+ value: function getComputedColliderSize() {
64807
+ const result = {};
64808
+ try {
64809
+ if (this.boundingBox) {
64810
+ const size = parseBoundingBoxSize(this.boundingBox);
64811
+ const scale = this.getScale();
64812
+ result.width = parseFloat((size.x * scale.x).toFixed(3));
64813
+ result.height = parseFloat((size.y * scale.y).toFixed(3));
64814
+ result.length = parseFloat((size.z * scale.z).toFixed(3));
64815
+ }
64816
+ if (this.boundingSphere) {
64817
+ result.radius = parseFloat(this.boundingSphere.radius.toFixed(3));
64818
+ }
64819
+ } catch {
64820
+ // bounding box/sphere not yet available
64821
+ }
64822
+ return result;
64823
+ }
64745
64824
  }, {
64746
64825
  key: "addToScene",
64747
64826
  value: function addToScene() {
@@ -65675,7 +65754,8 @@ let Element$1 = /*#__PURE__*/function (_Entity) {
65675
65754
  ..._superPropGet(Element, "toJSON", this, 3)([parseJSON]),
65676
65755
  // Physics options (state is not used by Importer, only options)
65677
65756
  physics: {
65678
- options: this.getPhysicsOptions()
65757
+ options: this.getPhysicsOptions(),
65758
+ computedSize: this.getComputedColliderSize()
65679
65759
  },
65680
65760
  // Textures with serialized map
65681
65761
  textures: serializeMap(this.textures),
@@ -92772,6 +92852,11 @@ let Level = /*#__PURE__*/function (_EventDispatcher) {
92772
92852
  } else {
92773
92853
  Scene$1.render(dt);
92774
92854
  }
92855
+
92856
+ // Render gizmo layer on top of everything (separate pass with depth clear)
92857
+ // This ensures gizmos are always visible regardless of sky, post-processing,
92858
+ // or the sortObjects=false setting used when shadows are enabled.
92859
+ Scene$1.renderGizmoLayer();
92775
92860
  Particles$1.update(dt);
92776
92861
  this.onUpdate(dt);
92777
92862
  Scene$1.update(dt);
@@ -98062,7 +98147,877 @@ let Sound = /*#__PURE__*/function (_Entity) {
98062
98147
  });
98063
98148
  }
98064
98149
  }]);
98065
- }(Entity);const BLOB_TYPE = "application/javascript";
98150
+ }(Entity);var LineSegmentsGeometry = function () {
98151
+
98152
+ InstancedBufferGeometry.call( this );
98153
+
98154
+ this.type = 'LineSegmentsGeometry';
98155
+
98156
+ var positions = [ - 1, 2, 0, 1, 2, 0, - 1, 1, 0, 1, 1, 0, - 1, 0, 0, 1, 0, 0, - 1, - 1, 0, 1, - 1, 0 ];
98157
+ var uvs = [ - 1, 2, 1, 2, - 1, 1, 1, 1, - 1, - 1, 1, - 1, - 1, - 2, 1, - 2 ];
98158
+ var index = [ 0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3, 4, 6, 5, 6, 7, 5 ];
98159
+
98160
+ this.setIndex( index );
98161
+ this.setAttribute( 'position', new Float32BufferAttribute( positions, 3 ) );
98162
+ this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
98163
+
98164
+ };
98165
+
98166
+ LineSegmentsGeometry.prototype = Object.assign( Object.create( InstancedBufferGeometry.prototype ), {
98167
+
98168
+ constructor: LineSegmentsGeometry,
98169
+
98170
+ isLineSegmentsGeometry: true,
98171
+
98172
+ applyMatrix4: function ( matrix ) {
98173
+
98174
+ var start = this.attributes.instanceStart;
98175
+ var end = this.attributes.instanceEnd;
98176
+
98177
+ if ( start !== undefined ) {
98178
+
98179
+ start.applyMatrix4( matrix );
98180
+
98181
+ end.applyMatrix4( matrix );
98182
+
98183
+ start.needsUpdate = true;
98184
+
98185
+ }
98186
+
98187
+ if ( this.boundingBox !== null ) {
98188
+
98189
+ this.computeBoundingBox();
98190
+
98191
+ }
98192
+
98193
+ if ( this.boundingSphere !== null ) {
98194
+
98195
+ this.computeBoundingSphere();
98196
+
98197
+ }
98198
+
98199
+ return this;
98200
+
98201
+ },
98202
+
98203
+ setPositions: function ( array ) {
98204
+
98205
+ var lineSegments;
98206
+
98207
+ if ( array instanceof Float32Array ) {
98208
+
98209
+ lineSegments = array;
98210
+
98211
+ } else if ( Array.isArray( array ) ) {
98212
+
98213
+ lineSegments = new Float32Array( array );
98214
+
98215
+ }
98216
+
98217
+ var instanceBuffer = new InstancedInterleavedBuffer( lineSegments, 6, 1 ); // xyz, xyz
98218
+
98219
+ this.setAttribute( 'instanceStart', new InterleavedBufferAttribute( instanceBuffer, 3, 0 ) ); // xyz
98220
+ this.setAttribute( 'instanceEnd', new InterleavedBufferAttribute( instanceBuffer, 3, 3 ) ); // xyz
98221
+
98222
+ //
98223
+
98224
+ this.computeBoundingBox();
98225
+ this.computeBoundingSphere();
98226
+
98227
+ return this;
98228
+
98229
+ },
98230
+
98231
+ setColors: function ( array ) {
98232
+
98233
+ var colors;
98234
+
98235
+ if ( array instanceof Float32Array ) {
98236
+
98237
+ colors = array;
98238
+
98239
+ } else if ( Array.isArray( array ) ) {
98240
+
98241
+ colors = new Float32Array( array );
98242
+
98243
+ }
98244
+
98245
+ var instanceColorBuffer = new InstancedInterleavedBuffer( colors, 6, 1 ); // rgb, rgb
98246
+
98247
+ this.setAttribute( 'instanceColorStart', new InterleavedBufferAttribute( instanceColorBuffer, 3, 0 ) ); // rgb
98248
+ this.setAttribute( 'instanceColorEnd', new InterleavedBufferAttribute( instanceColorBuffer, 3, 3 ) ); // rgb
98249
+
98250
+ return this;
98251
+
98252
+ },
98253
+
98254
+ fromWireframeGeometry: function ( geometry ) {
98255
+
98256
+ this.setPositions( geometry.attributes.position.array );
98257
+
98258
+ return this;
98259
+
98260
+ },
98261
+
98262
+ fromEdgesGeometry: function ( geometry ) {
98263
+
98264
+ this.setPositions( geometry.attributes.position.array );
98265
+
98266
+ return this;
98267
+
98268
+ },
98269
+
98270
+ fromMesh: function ( mesh ) {
98271
+
98272
+ this.fromWireframeGeometry( new WireframeGeometry( mesh.geometry ) );
98273
+
98274
+ // set colors, maybe
98275
+
98276
+ return this;
98277
+
98278
+ },
98279
+
98280
+ fromLineSegments: function ( lineSegments ) {
98281
+
98282
+ var geometry = lineSegments.geometry;
98283
+
98284
+ if ( geometry.isGeometry ) {
98285
+
98286
+ console.error( 'THREE.LineSegmentsGeometry no longer supports Geometry. Use THREE.BufferGeometry instead.' );
98287
+ return;
98288
+
98289
+ } else if ( geometry.isBufferGeometry ) {
98290
+
98291
+ this.setPositions( geometry.attributes.position.array ); // assumes non-indexed
98292
+
98293
+ }
98294
+
98295
+ // set colors, maybe
98296
+
98297
+ return this;
98298
+
98299
+ },
98300
+
98301
+ computeBoundingBox: function () {
98302
+
98303
+ var box = new Box3();
98304
+
98305
+ return function computeBoundingBox() {
98306
+
98307
+ if ( this.boundingBox === null ) {
98308
+
98309
+ this.boundingBox = new Box3();
98310
+
98311
+ }
98312
+
98313
+ var start = this.attributes.instanceStart;
98314
+ var end = this.attributes.instanceEnd;
98315
+
98316
+ if ( start !== undefined && end !== undefined ) {
98317
+
98318
+ this.boundingBox.setFromBufferAttribute( start );
98319
+
98320
+ box.setFromBufferAttribute( end );
98321
+
98322
+ this.boundingBox.union( box );
98323
+
98324
+ }
98325
+
98326
+ };
98327
+
98328
+ }(),
98329
+
98330
+ computeBoundingSphere: function () {
98331
+
98332
+ var vector = new Vector3$1();
98333
+
98334
+ return function computeBoundingSphere() {
98335
+
98336
+ if ( this.boundingSphere === null ) {
98337
+
98338
+ this.boundingSphere = new Sphere$1();
98339
+
98340
+ }
98341
+
98342
+ if ( this.boundingBox === null ) {
98343
+
98344
+ this.computeBoundingBox();
98345
+
98346
+ }
98347
+
98348
+ var start = this.attributes.instanceStart;
98349
+ var end = this.attributes.instanceEnd;
98350
+
98351
+ if ( start !== undefined && end !== undefined ) {
98352
+
98353
+ var center = this.boundingSphere.center;
98354
+
98355
+ this.boundingBox.getCenter( center );
98356
+
98357
+ var maxRadiusSq = 0;
98358
+
98359
+ for ( var i = 0, il = start.count; i < il; i ++ ) {
98360
+
98361
+ vector.fromBufferAttribute( start, i );
98362
+ maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) );
98363
+
98364
+ vector.fromBufferAttribute( end, i );
98365
+ maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) );
98366
+
98367
+ }
98368
+
98369
+ this.boundingSphere.radius = Math.sqrt( maxRadiusSq );
98370
+
98371
+ if ( isNaN( this.boundingSphere.radius ) ) {
98372
+
98373
+ console.error( 'THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.', this );
98374
+
98375
+ }
98376
+
98377
+ }
98378
+
98379
+ };
98380
+
98381
+ }(),
98382
+
98383
+ toJSON: function () {
98384
+
98385
+ // todo
98386
+
98387
+ },
98388
+
98389
+ applyMatrix: function ( matrix ) {
98390
+
98391
+ console.warn( 'THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4().' );
98392
+
98393
+ return this.applyMatrix4( matrix );
98394
+
98395
+ }
98396
+
98397
+ } );/**
98398
+ * parameters = {
98399
+ * color: <hex>,
98400
+ * linewidth: <float>,
98401
+ * dashed: <boolean>,
98402
+ * dashScale: <float>,
98403
+ * dashSize: <float>,
98404
+ * dashOffset: <float>,
98405
+ * gapSize: <float>,
98406
+ * resolution: <Vector2>, // to be set by renderer
98407
+ * }
98408
+ */
98409
+
98410
+ UniformsLib.line = {
98411
+
98412
+ linewidth: { value: 1 },
98413
+ resolution: { value: new Vector2( 1, 1 ) },
98414
+ dashScale: { value: 1 },
98415
+ dashSize: { value: 1 },
98416
+ dashOffset: { value: 0 },
98417
+ gapSize: { value: 1 }, // todo FIX - maybe change to totalSize
98418
+ opacity: { value: 1 }
98419
+
98420
+ };
98421
+
98422
+ ShaderLib[ 'line' ] = {
98423
+
98424
+ uniforms: UniformsUtils.merge( [
98425
+ UniformsLib.common,
98426
+ UniformsLib.fog,
98427
+ UniformsLib.line
98428
+ ] ),
98429
+
98430
+ vertexShader:
98431
+ `
98432
+ #include <common>
98433
+ #include <color_pars_vertex>
98434
+ #include <fog_pars_vertex>
98435
+ #include <logdepthbuf_pars_vertex>
98436
+ #include <clipping_planes_pars_vertex>
98437
+
98438
+ uniform float linewidth;
98439
+ uniform vec2 resolution;
98440
+
98441
+ attribute vec3 instanceStart;
98442
+ attribute vec3 instanceEnd;
98443
+
98444
+ attribute vec3 instanceColorStart;
98445
+ attribute vec3 instanceColorEnd;
98446
+
98447
+ varying vec2 vUv;
98448
+
98449
+ #ifdef USE_DASH
98450
+
98451
+ uniform float dashScale;
98452
+ attribute float instanceDistanceStart;
98453
+ attribute float instanceDistanceEnd;
98454
+ varying float vLineDistance;
98455
+
98456
+ #endif
98457
+
98458
+ void trimSegment( const in vec4 start, inout vec4 end ) {
98459
+
98460
+ // trim end segment so it terminates between the camera plane and the near plane
98461
+
98462
+ // conservative estimate of the near plane
98463
+ float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
98464
+ float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
98465
+ float nearEstimate = - 0.5 * b / a;
98466
+
98467
+ float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
98468
+
98469
+ end.xyz = mix( start.xyz, end.xyz, alpha );
98470
+
98471
+ }
98472
+
98473
+ void main() {
98474
+
98475
+ #ifdef USE_COLOR
98476
+
98477
+ vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
98478
+
98479
+ #endif
98480
+
98481
+ #ifdef USE_DASH
98482
+
98483
+ vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
98484
+
98485
+ #endif
98486
+
98487
+ float aspect = resolution.x / resolution.y;
98488
+
98489
+ vUv = uv;
98490
+
98491
+ // camera space
98492
+ vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
98493
+ vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
98494
+
98495
+ // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
98496
+ // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
98497
+ // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
98498
+ // perhaps there is a more elegant solution -- WestLangley
98499
+
98500
+ bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
98501
+
98502
+ if ( perspective ) {
98503
+
98504
+ if ( start.z < 0.0 && end.z >= 0.0 ) {
98505
+
98506
+ trimSegment( start, end );
98507
+
98508
+ } else if ( end.z < 0.0 && start.z >= 0.0 ) {
98509
+
98510
+ trimSegment( end, start );
98511
+
98512
+ }
98513
+
98514
+ }
98515
+
98516
+ // clip space
98517
+ vec4 clipStart = projectionMatrix * start;
98518
+ vec4 clipEnd = projectionMatrix * end;
98519
+
98520
+ // ndc space
98521
+ vec2 ndcStart = clipStart.xy / clipStart.w;
98522
+ vec2 ndcEnd = clipEnd.xy / clipEnd.w;
98523
+
98524
+ // direction
98525
+ vec2 dir = ndcEnd - ndcStart;
98526
+
98527
+ // account for clip-space aspect ratio
98528
+ dir.x *= aspect;
98529
+ dir = normalize( dir );
98530
+
98531
+ // perpendicular to dir
98532
+ vec2 offset = vec2( dir.y, - dir.x );
98533
+
98534
+ // undo aspect ratio adjustment
98535
+ dir.x /= aspect;
98536
+ offset.x /= aspect;
98537
+
98538
+ // sign flip
98539
+ if ( position.x < 0.0 ) offset *= - 1.0;
98540
+
98541
+ // endcaps
98542
+ if ( position.y < 0.0 ) {
98543
+
98544
+ offset += - dir;
98545
+
98546
+ } else if ( position.y > 1.0 ) {
98547
+
98548
+ offset += dir;
98549
+
98550
+ }
98551
+
98552
+ // adjust for linewidth
98553
+ offset *= linewidth;
98554
+
98555
+ // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
98556
+ offset /= resolution.y;
98557
+
98558
+ // select end
98559
+ vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
98560
+
98561
+ // back to clip space
98562
+ offset *= clip.w;
98563
+
98564
+ clip.xy += offset;
98565
+
98566
+ gl_Position = clip;
98567
+
98568
+ vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
98569
+
98570
+ #include <logdepthbuf_vertex>
98571
+ #include <clipping_planes_vertex>
98572
+ #include <fog_vertex>
98573
+
98574
+ }
98575
+ `,
98576
+
98577
+ fragmentShader:
98578
+ `
98579
+ uniform vec3 diffuse;
98580
+ uniform float opacity;
98581
+
98582
+ #ifdef USE_DASH
98583
+
98584
+ uniform float dashSize;
98585
+ uniform float dashOffset;
98586
+ uniform float gapSize;
98587
+
98588
+ #endif
98589
+
98590
+ varying float vLineDistance;
98591
+
98592
+ #include <common>
98593
+ #include <color_pars_fragment>
98594
+ #include <fog_pars_fragment>
98595
+ #include <logdepthbuf_pars_fragment>
98596
+ #include <clipping_planes_pars_fragment>
98597
+
98598
+ varying vec2 vUv;
98599
+
98600
+ void main() {
98601
+
98602
+ #include <clipping_planes_fragment>
98603
+
98604
+ #ifdef USE_DASH
98605
+
98606
+ if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
98607
+
98608
+ if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
98609
+
98610
+ #endif
98611
+
98612
+ if ( abs( vUv.y ) > 1.0 ) {
98613
+
98614
+ float a = vUv.x;
98615
+ float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
98616
+ float len2 = a * a + b * b;
98617
+
98618
+ if ( len2 > 1.0 ) discard;
98619
+
98620
+ }
98621
+
98622
+ vec4 diffuseColor = vec4( diffuse, opacity );
98623
+
98624
+ #include <logdepthbuf_fragment>
98625
+ #include <color_fragment>
98626
+
98627
+ gl_FragColor = vec4( diffuseColor.rgb, diffuseColor.a );
98628
+
98629
+ #include <tonemapping_fragment>
98630
+ #include <encodings_fragment>
98631
+ #include <fog_fragment>
98632
+ #include <premultiplied_alpha_fragment>
98633
+
98634
+ }
98635
+ `
98636
+ };
98637
+
98638
+ var LineMaterial = function ( parameters ) {
98639
+
98640
+ ShaderMaterial.call( this, {
98641
+
98642
+ type: 'LineMaterial',
98643
+
98644
+ uniforms: UniformsUtils.clone( ShaderLib[ 'line' ].uniforms ),
98645
+
98646
+ vertexShader: ShaderLib[ 'line' ].vertexShader,
98647
+ fragmentShader: ShaderLib[ 'line' ].fragmentShader,
98648
+
98649
+ clipping: true // required for clipping support
98650
+
98651
+ } );
98652
+
98653
+ this.dashed = false;
98654
+
98655
+ Object.defineProperties( this, {
98656
+
98657
+ color: {
98658
+
98659
+ enumerable: true,
98660
+
98661
+ get: function () {
98662
+
98663
+ return this.uniforms.diffuse.value;
98664
+
98665
+ },
98666
+
98667
+ set: function ( value ) {
98668
+
98669
+ this.uniforms.diffuse.value = value;
98670
+
98671
+ }
98672
+
98673
+ },
98674
+
98675
+ linewidth: {
98676
+
98677
+ enumerable: true,
98678
+
98679
+ get: function () {
98680
+
98681
+ return this.uniforms.linewidth.value;
98682
+
98683
+ },
98684
+
98685
+ set: function ( value ) {
98686
+
98687
+ this.uniforms.linewidth.value = value;
98688
+
98689
+ }
98690
+
98691
+ },
98692
+
98693
+ dashScale: {
98694
+
98695
+ enumerable: true,
98696
+
98697
+ get: function () {
98698
+
98699
+ return this.uniforms.dashScale.value;
98700
+
98701
+ },
98702
+
98703
+ set: function ( value ) {
98704
+
98705
+ this.uniforms.dashScale.value = value;
98706
+
98707
+ }
98708
+
98709
+ },
98710
+
98711
+ dashSize: {
98712
+
98713
+ enumerable: true,
98714
+
98715
+ get: function () {
98716
+
98717
+ return this.uniforms.dashSize.value;
98718
+
98719
+ },
98720
+
98721
+ set: function ( value ) {
98722
+
98723
+ this.uniforms.dashSize.value = value;
98724
+
98725
+ }
98726
+
98727
+ },
98728
+
98729
+ dashOffset: {
98730
+
98731
+ enumerable: true,
98732
+
98733
+ get: function () {
98734
+
98735
+ return this.uniforms.dashOffset.value;
98736
+
98737
+ },
98738
+
98739
+ set: function ( value ) {
98740
+
98741
+ this.uniforms.dashOffset.value = value;
98742
+
98743
+ }
98744
+
98745
+ },
98746
+
98747
+ gapSize: {
98748
+
98749
+ enumerable: true,
98750
+
98751
+ get: function () {
98752
+
98753
+ return this.uniforms.gapSize.value;
98754
+
98755
+ },
98756
+
98757
+ set: function ( value ) {
98758
+
98759
+ this.uniforms.gapSize.value = value;
98760
+
98761
+ }
98762
+
98763
+ },
98764
+
98765
+ opacity: {
98766
+
98767
+ enumerable: true,
98768
+
98769
+ get: function () {
98770
+
98771
+ return this.uniforms.opacity.value;
98772
+
98773
+ },
98774
+
98775
+ set: function ( value ) {
98776
+
98777
+ this.uniforms.opacity.value = value;
98778
+
98779
+ }
98780
+
98781
+ },
98782
+
98783
+ resolution: {
98784
+
98785
+ enumerable: true,
98786
+
98787
+ get: function () {
98788
+
98789
+ return this.uniforms.resolution.value;
98790
+
98791
+ },
98792
+
98793
+ set: function ( value ) {
98794
+
98795
+ this.uniforms.resolution.value.copy( value );
98796
+
98797
+ }
98798
+
98799
+ }
98800
+
98801
+ } );
98802
+
98803
+ this.setValues( parameters );
98804
+
98805
+ };
98806
+
98807
+ LineMaterial.prototype = Object.create( ShaderMaterial.prototype );
98808
+ LineMaterial.prototype.constructor = LineMaterial;
98809
+
98810
+ LineMaterial.prototype.isLineMaterial = true;var LineSegments2 = function ( geometry, material ) {
98811
+
98812
+ if ( geometry === undefined ) geometry = new LineSegmentsGeometry();
98813
+ if ( material === undefined ) material = new LineMaterial( { color: Math.random() * 0xffffff } );
98814
+
98815
+ Mesh.call( this, geometry, material );
98816
+
98817
+ this.type = 'LineSegments2';
98818
+
98819
+ };
98820
+
98821
+ LineSegments2.prototype = Object.assign( Object.create( Mesh.prototype ), {
98822
+
98823
+ constructor: LineSegments2,
98824
+
98825
+ isLineSegments2: true,
98826
+
98827
+ computeLineDistances: ( function () { // for backwards-compatability, but could be a method of LineSegmentsGeometry...
98828
+
98829
+ var start = new Vector3$1();
98830
+ var end = new Vector3$1();
98831
+
98832
+ return function computeLineDistances() {
98833
+
98834
+ var geometry = this.geometry;
98835
+
98836
+ var instanceStart = geometry.attributes.instanceStart;
98837
+ var instanceEnd = geometry.attributes.instanceEnd;
98838
+ var lineDistances = new Float32Array( 2 * instanceStart.data.count );
98839
+
98840
+ for ( var i = 0, j = 0, l = instanceStart.data.count; i < l; i ++, j += 2 ) {
98841
+
98842
+ start.fromBufferAttribute( instanceStart, i );
98843
+ end.fromBufferAttribute( instanceEnd, i );
98844
+
98845
+ lineDistances[ j ] = ( j === 0 ) ? 0 : lineDistances[ j - 1 ];
98846
+ lineDistances[ j + 1 ] = lineDistances[ j ] + start.distanceTo( end );
98847
+
98848
+ }
98849
+
98850
+ var instanceDistanceBuffer = new InstancedInterleavedBuffer( lineDistances, 2, 1 ); // d0, d1
98851
+
98852
+ geometry.setAttribute( 'instanceDistanceStart', new InterleavedBufferAttribute( instanceDistanceBuffer, 1, 0 ) ); // d0
98853
+ geometry.setAttribute( 'instanceDistanceEnd', new InterleavedBufferAttribute( instanceDistanceBuffer, 1, 1 ) ); // d1
98854
+
98855
+ return this;
98856
+
98857
+ };
98858
+
98859
+ }() ),
98860
+
98861
+ raycast: ( function () {
98862
+
98863
+ var start = new Vector4();
98864
+ var end = new Vector4();
98865
+
98866
+ var ssOrigin = new Vector4();
98867
+ var ssOrigin3 = new Vector3$1();
98868
+ var mvMatrix = new Matrix4();
98869
+ var line = new Line3();
98870
+ var closestPoint = new Vector3$1();
98871
+
98872
+ return function raycast( raycaster, intersects ) {
98873
+
98874
+ if ( raycaster.camera === null ) {
98875
+
98876
+ console.error( 'LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2.' );
98877
+
98878
+ }
98879
+
98880
+ var threshold = ( raycaster.params.Line2 !== undefined ) ? raycaster.params.Line2.threshold || 0 : 0;
98881
+
98882
+ var ray = raycaster.ray;
98883
+ var camera = raycaster.camera;
98884
+ var projectionMatrix = camera.projectionMatrix;
98885
+
98886
+ var geometry = this.geometry;
98887
+ var material = this.material;
98888
+ var resolution = material.resolution;
98889
+ var lineWidth = material.linewidth + threshold;
98890
+
98891
+ var instanceStart = geometry.attributes.instanceStart;
98892
+ var instanceEnd = geometry.attributes.instanceEnd;
98893
+
98894
+ // camera forward is negative
98895
+ var near = - camera.near;
98896
+
98897
+ // pick a point 1 unit out along the ray to avoid the ray origin
98898
+ // sitting at the camera origin which will cause "w" to be 0 when
98899
+ // applying the projection matrix.
98900
+ ray.at( 1, ssOrigin );
98901
+
98902
+ // ndc space [ - 1.0, 1.0 ]
98903
+ ssOrigin.w = 1;
98904
+ ssOrigin.applyMatrix4( camera.matrixWorldInverse );
98905
+ ssOrigin.applyMatrix4( projectionMatrix );
98906
+ ssOrigin.multiplyScalar( 1 / ssOrigin.w );
98907
+
98908
+ // screen space
98909
+ ssOrigin.x *= resolution.x / 2;
98910
+ ssOrigin.y *= resolution.y / 2;
98911
+ ssOrigin.z = 0;
98912
+
98913
+ ssOrigin3.copy( ssOrigin );
98914
+
98915
+ var matrixWorld = this.matrixWorld;
98916
+ mvMatrix.multiplyMatrices( camera.matrixWorldInverse, matrixWorld );
98917
+
98918
+ for ( var i = 0, l = instanceStart.count; i < l; i ++ ) {
98919
+
98920
+ start.fromBufferAttribute( instanceStart, i );
98921
+ end.fromBufferAttribute( instanceEnd, i );
98922
+
98923
+ start.w = 1;
98924
+ end.w = 1;
98925
+
98926
+ // camera space
98927
+ start.applyMatrix4( mvMatrix );
98928
+ end.applyMatrix4( mvMatrix );
98929
+
98930
+ // skip the segment if it's entirely behind the camera
98931
+ var isBehindCameraNear = start.z > near && end.z > near;
98932
+ if ( isBehindCameraNear ) {
98933
+
98934
+ continue;
98935
+
98936
+ }
98937
+
98938
+ // trim the segment if it extends behind camera near
98939
+ if ( start.z > near ) {
98940
+
98941
+ const deltaDist = start.z - end.z;
98942
+ const t = ( start.z - near ) / deltaDist;
98943
+ start.lerp( end, t );
98944
+
98945
+ } else if ( end.z > near ) {
98946
+
98947
+ const deltaDist = end.z - start.z;
98948
+ const t = ( end.z - near ) / deltaDist;
98949
+ end.lerp( start, t );
98950
+
98951
+ }
98952
+
98953
+ // clip space
98954
+ start.applyMatrix4( projectionMatrix );
98955
+ end.applyMatrix4( projectionMatrix );
98956
+
98957
+ // ndc space [ - 1.0, 1.0 ]
98958
+ start.multiplyScalar( 1 / start.w );
98959
+ end.multiplyScalar( 1 / end.w );
98960
+
98961
+ // screen space
98962
+ start.x *= resolution.x / 2;
98963
+ start.y *= resolution.y / 2;
98964
+
98965
+ end.x *= resolution.x / 2;
98966
+ end.y *= resolution.y / 2;
98967
+
98968
+ // create 2d segment
98969
+ line.start.copy( start );
98970
+ line.start.z = 0;
98971
+
98972
+ line.end.copy( end );
98973
+ line.end.z = 0;
98974
+
98975
+ // get closest point on ray to segment
98976
+ var param = line.closestPointToPointParameter( ssOrigin3, true );
98977
+ line.at( param, closestPoint );
98978
+
98979
+ // check if the intersection point is within clip space
98980
+ var zPos = MathUtils.lerp( start.z, end.z, param );
98981
+ var isInClipSpace = zPos >= - 1 && zPos <= 1;
98982
+
98983
+ var isInside = ssOrigin3.distanceTo( closestPoint ) < lineWidth * 0.5;
98984
+
98985
+ if ( isInClipSpace && isInside ) {
98986
+
98987
+ line.start.fromBufferAttribute( instanceStart, i );
98988
+ line.end.fromBufferAttribute( instanceEnd, i );
98989
+
98990
+ line.start.applyMatrix4( matrixWorld );
98991
+ line.end.applyMatrix4( matrixWorld );
98992
+
98993
+ var pointOnLine = new Vector3$1();
98994
+ var point = new Vector3$1();
98995
+
98996
+ ray.distanceSqToSegment( line.start, line.end, point, pointOnLine );
98997
+
98998
+ intersects.push( {
98999
+
99000
+ point: point,
99001
+ pointOnLine: pointOnLine,
99002
+ distance: ray.origin.distanceTo( point ),
99003
+
99004
+ object: this,
99005
+ face: null,
99006
+ faceIndex: i,
99007
+ uv: null,
99008
+ uv2: null,
99009
+
99010
+ } );
99011
+
99012
+ }
99013
+
99014
+ }
99015
+
99016
+ };
99017
+
99018
+ }() )
99019
+
99020
+ } );const BLOB_TYPE = "application/javascript";
98066
99021
  const createBlob = task => new Blob(["(", task.toString(), ")()"], {
98067
99022
  type: BLOB_TYPE
98068
99023
  });
@@ -98155,22 +99110,27 @@ const DEFAULT_HITBOX_OPTIONS = {
98155
99110
  shadowsEnabled: false
98156
99111
  };
98157
99112
  const getBoxHitbox = element => {
98158
- const size = new Vector3$1();
98159
- element.boundingBox.getSize(size);
98160
- const scaledSize = {
98161
- x: size.x + HIT_BOX_INCREASE,
98162
- y: size.y + HIT_BOX_INCREASE,
98163
- z: size.z + HIT_BOX_INCREASE
98164
- };
98165
- const box = new Box(scaledSize.x, scaledSize.y, scaledSize.z, HIT_BOX_COLOR, DEFAULT_HITBOX_OPTIONS);
98166
-
98167
- //box.setQuaternion(quaternion);
99113
+ const opts = element.getPhysicsOptions() || {};
99114
+ let w, h, l;
99115
+ if (opts.colliderWidth != null || opts.colliderHeight != null || opts.colliderLength != null) {
99116
+ w = (opts.colliderWidth ?? 1) + HIT_BOX_INCREASE;
99117
+ h = (opts.colliderHeight ?? 1) + HIT_BOX_INCREASE;
99118
+ l = (opts.colliderLength ?? 1) + HIT_BOX_INCREASE;
99119
+ } else {
99120
+ const size = new Vector3$1();
99121
+ element.boundingBox.getSize(size);
99122
+ w = size.x + HIT_BOX_INCREASE;
99123
+ h = size.y + HIT_BOX_INCREASE;
99124
+ l = size.z + HIT_BOX_INCREASE;
99125
+ }
99126
+ const box = new Box(w, h, l, HIT_BOX_COLOR, DEFAULT_HITBOX_OPTIONS);
98168
99127
  box.setWireframe(true);
98169
99128
  box.setWireframeLineWidth(2);
98170
99129
  return box;
98171
99130
  };
98172
99131
  const getSphereHitbox = element => {
98173
- const radius = element.boundingSphere.radius;
99132
+ const opts = element.getPhysicsOptions() || {};
99133
+ const radius = opts.colliderRadius != null ? opts.colliderRadius : element.boundingSphere.radius;
98174
99134
  const sphere = new Sphere(radius, HIT_BOX_COLOR, DEFAULT_HITBOX_OPTIONS);
98175
99135
  sphere.setWireframe(true);
98176
99136
  sphere.setWireframeLineWidth(2);
@@ -100314,4 +101274,4 @@ var Shaders$1 = new Shaders();let Shader = /*#__PURE__*/_createClass(function Sh
100314
101274
  ...light_contants,
100315
101275
  ...material_constants,
100316
101276
  ...controls_contants
100317
- };export{AUDIO_RAMPS,AmbientLight,AmbientSound,Atmosphere,Audio$1 as Audio,Axes,BUILTIN,BaseScript,Box,CONTROL_EVENTS,Camera,Color,Cone,Config$1 as Config,Controls$1 as Controls,Cube,CurveLine,Cylinder,DirectionalSound,ENTITY_EVENTS,ENTITY_TYPES,Element$1 as Element,Entity,EventDispatcher,Explosion,Exporter,FEATURES,Features$1 as Features,Fire,Fountain,GameRunner$1 as GameRunner,Grid,HelperSprite,HemisphereLight,INPUT_EVENTS,Images$1 as Images,Importer,Input$1 as Input,Label,LabelComponent,Level,Lights$1 as Lights,Line,MirrorElement as Mirror,Models$1 as Models,Ocean,PALETTES,PARTICLES,PHYSICS_CONSTANTS,PHYSICS_EVENTS,ParticleEmitter,ParticleEmitterGroup,Particles$1 as Particles,Physics$1 as Physics,Plane,PointLight,PostProcessing$1 as PostProcessing,Proton,ProtonParticleEmitter,Provider,Rain,Router$1 as Router,Scene$1 as Scene,Scripts$1 as Scripts,Shader,Sky,Skybox,Snow,Sound,Sphere,SpotLight,Sprite,Stats$1 as Stats,SunLight,three_module as THREE,THREEJS_CONTROL_EVENTS,Trail,Universe$1 as Universe,Vector3$1 as Vector3,Water,author,connect,constants,createElement,easing,functions,hitbox as hitboxUtils,index_esm as inferno,map$1 as map,math,object,physicsUtils,index$1 as rxjs,index as store,strings,uuid$1 as uuid,workers,index$2 as xstate};
101277
+ };export{AUDIO_RAMPS,AmbientLight,AmbientSound,Atmosphere,Audio$1 as Audio,Axes,BUILTIN,BaseScript,Box,CONTROL_EVENTS,Camera,Color,Cone,Config$1 as Config,Controls$1 as Controls,Cube,CurveLine,Cylinder,DirectionalSound,ENTITY_EVENTS,ENTITY_TYPES,Element$1 as Element,Entity,EventDispatcher,Explosion,Exporter,FEATURES,Features$1 as Features,Fire,Fountain,GameRunner$1 as GameRunner,Grid,HelperSprite,HemisphereLight,INPUT_EVENTS,Images$1 as Images,Importer,Input$1 as Input,Label,LabelComponent,Level,Lights$1 as Lights,Line,LineMaterial,LineSegments2,LineSegmentsGeometry,MirrorElement as Mirror,Models$1 as Models,Ocean,PALETTES,PARTICLES,PHYSICS_CONSTANTS,PHYSICS_EVENTS,ParticleEmitter,ParticleEmitterGroup,Particles$1 as Particles,Physics$1 as Physics,Plane,PointLight,PostProcessing$1 as PostProcessing,Proton,ProtonParticleEmitter,Provider,Rain,Router$1 as Router,Scene$1 as Scene,Scripts$1 as Scripts,Shader,Sky,Skybox,Snow,Sound,Sphere,SpotLight,Sprite,Stats$1 as Stats,SunLight,three_module as THREE,THREEJS_CONTROL_EVENTS,Trail,Universe$1 as Universe,Vector3$1 as Vector3,Water,author,connect,constants,createElement,easing,functions,hitbox as hitboxUtils,index_esm as inferno,map$1 as map,math,object,physicsUtils,index$1 as rxjs,index as store,strings,uuid$1 as uuid,workers,index$2 as xstate};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mage-engine",
3
- "version": "3.25.6",
3
+ "version": "3.25.7",
4
4
  "description": "A WebGL Javascript Game Engine, built on top of THREE.js and many other libraries.",
5
5
  "main": "dist/mage.js",
6
6
  "author": {