@galacean/engine-physics-lite 0.0.0-experimental-0.9-plus.5 → 0.0.0-experimental-0.9-plus.6

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.
@@ -10031,6 +10031,14 @@ exports.Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10031
10031
  };
10032
10032
  /**
10033
10033
  * @internal
10034
+ */ _proto._cloneTo = function _cloneTo(target) {
10035
+ var materials = this._materials;
10036
+ for(var i = 0, n = materials.length; i < n; i++){
10037
+ target._setMaterial(i, materials[i]);
10038
+ }
10039
+ };
10040
+ /**
10041
+ * @internal
10034
10042
  */ _proto._onDestroy = function _onDestroy() {
10035
10043
  this.entity.transform._updateFlagManager.removeListener(this._onTransformChanged);
10036
10044
  this.shaderData._addRefCount(-1);
@@ -10209,7 +10217,7 @@ __decorate$1([
10209
10217
  ignoreClone
10210
10218
  ], exports.Renderer.prototype, "_overrideUpdate", void 0);
10211
10219
  __decorate$1([
10212
- shallowClone
10220
+ ignoreClone
10213
10221
  ], exports.Renderer.prototype, "_materials", void 0);
10214
10222
  __decorate$1([
10215
10223
  ignoreClone
@@ -10424,6 +10432,7 @@ SimpleSpriteAssembler = __decorate$1([
10424
10432
  /**
10425
10433
  * @internal
10426
10434
  */ _proto._cloneTo = function _cloneTo(target) {
10435
+ Renderer.prototype._cloneTo.call(this, target);
10427
10436
  target.sprite = this._sprite;
10428
10437
  };
10429
10438
  /**
@@ -12849,6 +12858,7 @@ var VertexChangedFlags;
12849
12858
  /**
12850
12859
  * @internal
12851
12860
  */ _proto._cloneTo = function _cloneTo(target) {
12861
+ Renderer.prototype._cloneTo.call(this, target);
12852
12862
  target.mesh = this._mesh;
12853
12863
  };
12854
12864
  /**
@@ -19732,6 +19742,7 @@ SlicedSpriteAssembler = __decorate$1([
19732
19742
  /**
19733
19743
  * @internal
19734
19744
  */ _proto._cloneTo = function _cloneTo(target) {
19745
+ Renderer.prototype._cloneTo.call(this, target);
19735
19746
  target.sprite = this._sprite;
19736
19747
  target.drawMode = this._drawMode;
19737
19748
  };
@@ -20481,6 +20492,7 @@ var /**
20481
20492
  /**
20482
20493
  * @internal
20483
20494
  */ _proto._cloneTo = function _cloneTo(target) {
20495
+ Renderer.prototype._cloneTo.call(this, target);
20484
20496
  target.font = this._font;
20485
20497
  target._subFont = this._subFont;
20486
20498
  };
@@ -34271,38 +34283,6 @@ function _inherits(subClass, superClass) {
34271
34283
  });
34272
34284
  if (superClass) _set_prototype_of(subClass, superClass);
34273
34285
  }
34274
- /**
34275
- * WebGL platform engine,support includes WebGL1.0 and WebGL2.0.
34276
- */ var WebGLEngine = /*#__PURE__*/ function(Engine) {
34277
- var WebGLEngine = function WebGLEngine() {
34278
- return Engine.apply(this, arguments);
34279
- };
34280
- _inherits(WebGLEngine, Engine);
34281
- /**
34282
- * Create a WebGL engine.
34283
- * @param configuration - WebGL engine configuration
34284
- * @returns A promise that will resolve when the engine is created
34285
- */ WebGLEngine.create = function create(configuration) {
34286
- var canvas = configuration.canvas;
34287
- var webCanvas = new WebCanvas(typeof canvas === "string" ? engineMiniprogramAdapter.document.getElementById(canvas) : canvas);
34288
- var webGLGraphicDevice = new WebGLGraphicDevice(configuration.graphicDeviceOptions);
34289
- var engine = new WebGLEngine(webCanvas, webGLGraphicDevice, configuration);
34290
- // @ts-ignore
34291
- return engine._initialize(configuration);
34292
- };
34293
- _create_class(WebGLEngine, [
34294
- {
34295
- key: "canvas",
34296
- get: /**
34297
- * Web canvas.
34298
- */ function get() {
34299
- // @ts-ignore
34300
- return this._canvas;
34301
- }
34302
- }
34303
- ]);
34304
- return WebGLEngine;
34305
- }(miniprogram$1$1.Engine);
34306
34286
  function _extends() {
34307
34287
  _extends = Object.assign || function assign(target) {
34308
34288
  for(var i = 1; i < arguments.length; i++){
@@ -34313,83 +34293,6 @@ function _extends() {
34313
34293
  };
34314
34294
  return _extends.apply(this, arguments);
34315
34295
  }
34316
- var GLBuffer = /*#__PURE__*/ function() {
34317
- var GLBuffer = function GLBuffer(rhi, type, byteLength, bufferUsage, data) {
34318
- if (bufferUsage === void 0) bufferUsage = miniprogram$1$1.BufferUsage.Static;
34319
- var gl = rhi.gl;
34320
- var glBuffer = gl.createBuffer();
34321
- var glBufferUsage = this._getGLBufferUsage(gl, bufferUsage);
34322
- var glBindTarget = type === miniprogram$1$1.BufferBindFlag.VertexBuffer ? gl.ARRAY_BUFFER : gl.ELEMENT_ARRAY_BUFFER;
34323
- this._gl = gl;
34324
- this._glBuffer = glBuffer;
34325
- this._glBufferUsage = glBufferUsage;
34326
- this._glBindTarget = glBindTarget;
34327
- this._isWebGL2 = rhi.isWebGL2;
34328
- this.bind();
34329
- if (data) {
34330
- gl.bufferData(glBindTarget, data, glBufferUsage);
34331
- } else {
34332
- gl.bufferData(glBindTarget, byteLength, glBufferUsage);
34333
- }
34334
- gl.bindBuffer(glBindTarget, null);
34335
- };
34336
- var _proto = GLBuffer.prototype;
34337
- _proto.bind = function bind() {
34338
- this._gl.bindBuffer(this._glBindTarget, this._glBuffer);
34339
- };
34340
- _proto.setData = function setData(byteLength, data, bufferByteOffset, dataOffset, dataLength, options) {
34341
- var gl = this._gl;
34342
- var glBindTarget = this._glBindTarget;
34343
- this.bind();
34344
- if (options === miniprogram$1$1.SetDataOptions.Discard) {
34345
- gl.bufferData(glBindTarget, byteLength, this._glBufferUsage);
34346
- }
34347
- // TypeArray is BYTES_PER_ELEMENT, unTypeArray is 1
34348
- var byteSize = data.BYTES_PER_ELEMENT || 1;
34349
- var dataByteLength = dataLength ? byteSize * dataLength : data.byteLength;
34350
- if (dataOffset !== 0 || dataByteLength < data.byteLength) {
34351
- var isArrayBufferView = data.byteOffset !== undefined;
34352
- if (this._isWebGL2 && isArrayBufferView) {
34353
- gl.bufferSubData(glBindTarget, bufferByteOffset, data, dataOffset, dataByteLength / byteSize);
34354
- } else {
34355
- var subData = new Uint8Array(isArrayBufferView ? data.buffer : data, dataOffset * byteSize, dataByteLength);
34356
- gl.bufferSubData(glBindTarget, bufferByteOffset, subData);
34357
- }
34358
- } else {
34359
- gl.bufferSubData(glBindTarget, bufferByteOffset, data);
34360
- }
34361
- gl.bindBuffer(glBindTarget, null);
34362
- };
34363
- _proto.getData = function getData(data, bufferByteOffset, dataOffset, dataLength) {
34364
- if (this._isWebGL2) {
34365
- var gl = this._gl;
34366
- this.bind();
34367
- gl.getBufferSubData(this._glBindTarget, bufferByteOffset, data, dataOffset, dataLength);
34368
- } else {
34369
- throw "Buffer is write-only on WebGL1.0 platforms.";
34370
- }
34371
- };
34372
- _proto.resize = function resize(byteLength) {
34373
- this.bind();
34374
- this._gl.bufferData(this._glBindTarget, byteLength, this._glBufferUsage);
34375
- };
34376
- _proto.destroy = function destroy() {
34377
- this._gl.deleteBuffer(this._glBuffer);
34378
- this._gl = null;
34379
- this._glBuffer = null;
34380
- };
34381
- _proto._getGLBufferUsage = function _getGLBufferUsage(gl, bufferUsage) {
34382
- switch(bufferUsage){
34383
- case miniprogram$1$1.BufferUsage.Static:
34384
- return gl.STATIC_DRAW;
34385
- case miniprogram$1$1.BufferUsage.Dynamic:
34386
- return gl.DYNAMIC_DRAW;
34387
- case miniprogram$1$1.BufferUsage.Stream:
34388
- return gl.STREAM_DRAW;
34389
- }
34390
- };
34391
- return GLBuffer;
34392
- }();
34393
34296
  /**
34394
34297
  * GL capability.
34395
34298
  */ var GLCapability = /*#__PURE__*/ function() {
@@ -34652,8 +34555,8 @@ var GLBuffer = /*#__PURE__*/ function() {
34652
34555
  if (useVao) {
34653
34556
  gl.drawElements(topology, count, _glIndexType, start * _glIndexByteCount);
34654
34557
  } else {
34655
- var _glBuffer = _indexBufferBinding.buffer._platformBuffer._glBuffer;
34656
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _glBuffer);
34558
+ var _nativeBuffer = _indexBufferBinding.buffer._nativeBuffer;
34559
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _nativeBuffer);
34657
34560
  gl.drawElements(topology, count, _glIndexType, start * _glIndexByteCount);
34658
34561
  gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
34659
34562
  }
@@ -34666,8 +34569,8 @@ var GLBuffer = /*#__PURE__*/ function() {
34666
34569
  if (useVao) {
34667
34570
  gl.drawElementsInstanced(topology, count, _glIndexType, start * _glIndexByteCount, _instanceCount);
34668
34571
  } else {
34669
- var _glBuffer1 = _indexBufferBinding.buffer._platformBuffer._glBuffer;
34670
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _glBuffer1);
34572
+ var _nativeBuffer1 = _indexBufferBinding.buffer._nativeBuffer;
34573
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _nativeBuffer1);
34671
34574
  gl.drawElementsInstanced(topology, count, _glIndexType, start * _glIndexByteCount, _instanceCount);
34672
34575
  gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
34673
34576
  }
@@ -34707,7 +34610,7 @@ var GLBuffer = /*#__PURE__*/ function() {
34707
34610
  var element = attributes[name];
34708
34611
  if (element) {
34709
34612
  var _vertexBufferBindings_element_bindingIndex = vertexBufferBindings[element.bindingIndex], buffer = _vertexBufferBindings_element_bindingIndex.buffer, stride = _vertexBufferBindings_element_bindingIndex.stride;
34710
- vbo = buffer._platformBuffer._glBuffer;
34613
+ vbo = buffer._nativeBuffer;
34711
34614
  // prevent binding the vbo which already bound at the last loop, e.g. a buffer with multiple attributes.
34712
34615
  if (lastBoundVbo !== vbo) {
34713
34616
  lastBoundVbo = vbo;
@@ -34739,7 +34642,7 @@ var GLBuffer = /*#__PURE__*/ function() {
34739
34642
  // @ts-ignore
34740
34643
  var _indexBufferBinding = this._primitive._indexBufferBinding;
34741
34644
  if (_indexBufferBinding) {
34742
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _indexBufferBinding.buffer._platformBuffer._glBuffer);
34645
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _indexBufferBinding.buffer._nativeBuffer);
34743
34646
  }
34744
34647
  this._bindBufferAndAttrib(shaderProgram);
34745
34648
  /** unbind */ gl.bindVertexArray(null);
@@ -35796,21 +35699,23 @@ exports.WebGLMode = void 0;
35796
35699
  WebGLMode[WebGLMode[/** WebGL1.0, */ "WebGL1"] = 2] = "WebGL1";
35797
35700
  })(exports.WebGLMode || (exports.WebGLMode = {}));
35798
35701
  /**
35799
- * WebGL graphic device, including WebGL1.0 and WebGL2.0.
35800
- */ var WebGLGraphicDevice = /*#__PURE__*/ function() {
35801
- var WebGLGraphicDevice = function WebGLGraphicDevice(initializeOptions) {
35702
+ * WebGL renderer, including WebGL1.0 and WebGL2.0.
35703
+ */ var WebGLRenderer = /*#__PURE__*/ function() {
35704
+ var WebGLRenderer = function WebGLRenderer(initializeOptions) {
35802
35705
  if (initializeOptions === void 0) initializeOptions = {};
35803
- /** @internal */ this._readFrameBuffer = null;
35804
35706
  /** @internal */ this._enableGlobalDepthBias = false;
35805
35707
  this._activeTextures = new Array(32);
35708
+ // cache value
35806
35709
  this._lastViewport = new miniprogram$1.Vector4(null, null, null, null);
35807
35710
  this._lastScissor = new miniprogram$1.Vector4(null, null, null, null);
35808
35711
  this._lastClearColor = new miniprogram$1.Color(null, null, null, null);
35809
35712
  this._scissorEnable = false;
35810
35713
  var options = _extends({
35811
35714
  webGLMode: 0,
35715
+ alpha: false,
35812
35716
  stencil: true,
35813
- _forceFlush: false
35717
+ _forceFlush: false,
35718
+ _maxAllowSkinUniformVectorCount: 256
35814
35719
  }, initializeOptions);
35815
35720
  if (miniprogram$1$1.SystemInfo.platform === miniprogram$1$1.Platform.IPhone || miniprogram$1$1.SystemInfo.platform === miniprogram$1$1.Platform.IPad) {
35816
35721
  var version = miniprogram$1$1.SystemInfo.operatingSystem.match(/(\d+).?(\d+)?.?(\d+)?/);
@@ -35823,20 +35728,12 @@ exports.WebGLMode = void 0;
35823
35728
  }
35824
35729
  }
35825
35730
  this._options = options;
35826
- this._onWebGLContextLost = this._onWebGLContextLost.bind(this);
35827
- this._onWebGLContextRestored = this._onWebGLContextRestored.bind(this);
35828
35731
  };
35829
- var _proto = WebGLGraphicDevice.prototype;
35830
- _proto.init = function init(canvas, onDeviceLost, onDeviceRestored) {
35732
+ var _proto = WebGLRenderer.prototype;
35733
+ _proto.init = function init(canvas) {
35831
35734
  var options = this._options;
35832
- var webCanvas = canvas._webCanvas;
35735
+ var webCanvas = this._webCanvas = canvas._webCanvas;
35833
35736
  var webGLMode = options.webGLMode;
35834
- this._onDeviceLost = onDeviceLost;
35835
- this._onDeviceRestored = onDeviceRestored;
35836
- webCanvas.addEventListener("webglcontextlost", this._onWebGLContextLost, false);
35837
- webCanvas.addEventListener("webglcontextrestored", this._onWebGLContextRestored, false);
35838
- webCanvas.addEventListener("webglcontextcreationerror", this._onContextCreationError, false);
35839
- this._webCanvas = webCanvas;
35840
35737
  var gl;
35841
35738
  if (webGLMode == 0 || webGLMode == 1) {
35842
35739
  gl = webCanvas.getContext("webgl2", options);
@@ -35862,7 +35759,16 @@ exports.WebGLMode = void 0;
35862
35759
  throw new Error("Get GL Context FAILED.");
35863
35760
  }
35864
35761
  this._gl = gl;
35865
- this._initGLState(gl);
35762
+ this._activeTextureID = gl.TEXTURE0;
35763
+ this._renderStates = new GLRenderStates(gl);
35764
+ this._extensions = new GLExtensions(this);
35765
+ this._capability = new GLCapability(this);
35766
+ // Make sure the active texture in gl context is on default, because gl context may be used in other webgl renderer.
35767
+ gl.activeTexture(gl.TEXTURE0);
35768
+ var debugRenderInfo = gl.getExtension("WEBGL_debug_renderer_info");
35769
+ if (debugRenderInfo != null) {
35770
+ this._renderer = gl.getParameter(debugRenderInfo.UNMASKED_RENDERER_WEBGL);
35771
+ }
35866
35772
  };
35867
35773
  _proto.createPlatformPrimitive = function createPlatformPrimitive(primitive) {
35868
35774
  return new GLPrimitive(this, primitive);
@@ -35879,10 +35785,6 @@ exports.WebGLMode = void 0;
35879
35785
  _proto.createPlatformRenderTarget = function createPlatformRenderTarget(target) {
35880
35786
  return new GLRenderTarget(this, target);
35881
35787
  };
35882
- _proto.createPlatformBuffer = function createPlatformBuffer(type, byteLength, bufferUsage, data) {
35883
- if (bufferUsage === void 0) bufferUsage = miniprogram$1$1.BufferUsage.Static;
35884
- return new GLBuffer(this, type, byteLength, bufferUsage, data);
35885
- };
35886
35788
  _proto.requireExtension = function requireExtension(ext) {
35887
35789
  return this._extensions.requireExtension(ext);
35888
35790
  };
@@ -36010,57 +35912,8 @@ exports.WebGLMode = void 0;
36010
35912
  _proto.flush = function flush() {
36011
35913
  this._gl.flush();
36012
35914
  };
36013
- _proto.forceLoseDevice = function forceLoseDevice() {
36014
- var extension = this.requireExtension(miniprogram$1$1.GLCapabilityType.WEBGL_lose_context);
36015
- extension.loseContext();
36016
- };
36017
- _proto.forceRestoreDevice = function forceRestoreDevice() {
36018
- var extension = this.requireExtension(miniprogram$1$1.GLCapabilityType.WEBGL_lose_context);
36019
- extension.restoreContext();
36020
- };
36021
- _proto.resetState = function resetState() {
36022
- this._readFrameBuffer = null;
36023
- this._enableGlobalDepthBias = false;
36024
- this._currentBindShaderProgram = null;
36025
- var activeTextures = this._activeTextures;
36026
- for(var i = 0, n = activeTextures.length; i < n; i++){
36027
- activeTextures[i] = null;
36028
- }
36029
- this._lastViewport.set(null, null, null, null);
36030
- this._lastScissor.set(null, null, null, null);
36031
- this._lastClearColor.set(null, null, null, null);
36032
- this._scissorEnable = false;
36033
- this._initGLState(this._gl);
36034
- };
36035
- _proto._initGLState = function _initGLState(gl) {
36036
- this._activeTextureID = gl.TEXTURE0;
36037
- this._renderStates = new GLRenderStates(gl);
36038
- this._extensions = new GLExtensions(this);
36039
- this._capability = new GLCapability(this);
36040
- // Make sure the active texture in gl context is on default, because gl context may be used in other webgl renderer.
36041
- gl.activeTexture(gl.TEXTURE0);
36042
- var debugRenderInfo = gl.getExtension("WEBGL_debug_renderer_info");
36043
- if (debugRenderInfo != null) {
36044
- this._renderer = gl.getParameter(debugRenderInfo.UNMASKED_RENDERER_WEBGL);
36045
- }
36046
- };
36047
- _proto.destroy = function destroy() {
36048
- var webCanvas = this._webCanvas;
36049
- webCanvas.removeEventListener("webglcontextcreationerror", this._onContextCreationError, false);
36050
- webCanvas.removeEventListener("webglcontextlost", this._onWebGLContextLost, false);
36051
- webCanvas.removeEventListener("webglcontextrestored", this._onWebGLContextRestored, false);
36052
- };
36053
- _proto._onContextCreationError = function _onContextCreationError(event) {
36054
- console.error("WebGLRenderer: WebGL context could not be created. Reason: ", event.statusMessage);
36055
- };
36056
- _proto._onWebGLContextLost = function _onWebGLContextLost(event) {
36057
- event.preventDefault();
36058
- this._onDeviceLost();
36059
- };
36060
- _proto._onWebGLContextRestored = function _onWebGLContextRestored(event) {
36061
- this._onDeviceRestored();
36062
- };
36063
- _create_class(WebGLGraphicDevice, [
35915
+ _proto.destroy = function destroy() {};
35916
+ _create_class(WebGLRenderer, [
36064
35917
  {
36065
35918
  key: "isWebGL2",
36066
35919
  get: function get() {
@@ -36101,11 +35954,32 @@ exports.WebGLMode = void 0;
36101
35954
  }
36102
35955
  }
36103
35956
  ]);
36104
- return WebGLGraphicDevice;
35957
+ return WebGLRenderer;
36105
35958
  }();
35959
+ /**
35960
+ * WebGL platform engine,support includes WebGL1.0 and WebGL2.0.
35961
+ */ var WebGLEngine = /*#__PURE__*/ function(Engine) {
35962
+ var WebGLEngine = function WebGLEngine(canvas, webGLRendererOptions) {
35963
+ var webCanvas = new WebCanvas(typeof canvas === "string" ? engineMiniprogramAdapter.document.getElementById(canvas) : canvas);
35964
+ var hardwareRenderer = new WebGLRenderer(webGLRendererOptions);
35965
+ return Engine.call(this, webCanvas, hardwareRenderer);
35966
+ };
35967
+ _inherits(WebGLEngine, Engine);
35968
+ _create_class(WebGLEngine, [
35969
+ {
35970
+ key: "canvas",
35971
+ get: /**
35972
+ * Web canvas.
35973
+ */ function get() {
35974
+ return this._canvas;
35975
+ }
35976
+ }
35977
+ ]);
35978
+ return WebGLEngine;
35979
+ }(miniprogram$1$1.Engine);
36106
35980
  exports.WebCanvas = WebCanvas;
36107
35981
  exports.WebGLEngine = WebGLEngine;
36108
- exports.WebGLGraphicDevice = WebGLGraphicDevice;
35982
+ exports.WebGLRenderer = WebGLRenderer;
36109
35983
 
36110
35984
  var miniprogram$3 = /*#__PURE__*/Object.freeze({
36111
35985
  __proto__: null
@@ -36146,7 +36020,7 @@ function _interopNamespace(e) {
36146
36020
  }
36147
36021
  var CoreObjects__namespace = /*#__PURE__*/ _interopNamespace(CoreObjects);
36148
36022
  //@ts-ignore
36149
- var version = "0.0.0-experimental-0.9-plus.5";
36023
+ var version = "0.0.0-experimental-0.9-plus.6";
36150
36024
  console.log("Galacean engine version: " + version);
36151
36025
  for(var key in CoreObjects__namespace){
36152
36026
  CoreObjects.Loader.registerClass(key, CoreObjects__namespace[key]);