@galacean/engine-physics-lite 0.0.0-experimental-0.9-plus.3 → 0.0.0-experimental-0.9-plus.4

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.
@@ -29088,7 +29088,9 @@ var KHR_materials_ior = /*#__PURE__*/ function(GLTFExtensionParser) {
29088
29088
  };
29089
29089
  _inherits$1(KHR_materials_ior, GLTFExtensionParser);
29090
29090
  var _proto = KHR_materials_ior.prototype;
29091
- _proto.parseEngineResource = function parseEngineResource(schema, material, context) {
29091
+ /**
29092
+ * @override
29093
+ */ _proto.additiveParse = function additiveParse(context, material, schema) {
29092
29094
  var _schema_ior = schema.ior, ior = _schema_ior === void 0 ? 1.5 : _schema_ior;
29093
29095
  material.ior = ior;
29094
29096
  };
@@ -34258,38 +34260,6 @@ function _inherits(subClass, superClass) {
34258
34260
  });
34259
34261
  if (superClass) _set_prototype_of(subClass, superClass);
34260
34262
  }
34261
- /**
34262
- * WebGL platform engine,support includes WebGL1.0 and WebGL2.0.
34263
- */ var WebGLEngine = /*#__PURE__*/ function(Engine) {
34264
- var WebGLEngine = function WebGLEngine() {
34265
- return Engine.apply(this, arguments);
34266
- };
34267
- _inherits(WebGLEngine, Engine);
34268
- /**
34269
- * Create a WebGL engine.
34270
- * @param configuration - WebGL engine configuration
34271
- * @returns A promise that will resolve when the engine is created
34272
- */ WebGLEngine.create = function create(configuration) {
34273
- var canvas = configuration.canvas;
34274
- var webCanvas = new WebCanvas(typeof canvas === "string" ? engineMiniprogramAdapter.document.getElementById(canvas) : canvas);
34275
- var webGLGraphicDevice = new WebGLGraphicDevice(configuration.graphicDeviceOptions);
34276
- var engine = new WebGLEngine(webCanvas, webGLGraphicDevice, configuration);
34277
- // @ts-ignore
34278
- return engine._initialize(configuration);
34279
- };
34280
- _create_class(WebGLEngine, [
34281
- {
34282
- key: "canvas",
34283
- get: /**
34284
- * Web canvas.
34285
- */ function get() {
34286
- // @ts-ignore
34287
- return this._canvas;
34288
- }
34289
- }
34290
- ]);
34291
- return WebGLEngine;
34292
- }(miniprogram$1$1.Engine);
34293
34263
  function _extends() {
34294
34264
  _extends = Object.assign || function assign(target) {
34295
34265
  for(var i = 1; i < arguments.length; i++){
@@ -34300,83 +34270,6 @@ function _extends() {
34300
34270
  };
34301
34271
  return _extends.apply(this, arguments);
34302
34272
  }
34303
- var GLBuffer = /*#__PURE__*/ function() {
34304
- var GLBuffer = function GLBuffer(rhi, type, byteLength, bufferUsage, data) {
34305
- if (bufferUsage === void 0) bufferUsage = miniprogram$1$1.BufferUsage.Static;
34306
- var gl = rhi.gl;
34307
- var glBuffer = gl.createBuffer();
34308
- var glBufferUsage = this._getGLBufferUsage(gl, bufferUsage);
34309
- var glBindTarget = type === miniprogram$1$1.BufferBindFlag.VertexBuffer ? gl.ARRAY_BUFFER : gl.ELEMENT_ARRAY_BUFFER;
34310
- this._gl = gl;
34311
- this._glBuffer = glBuffer;
34312
- this._glBufferUsage = glBufferUsage;
34313
- this._glBindTarget = glBindTarget;
34314
- this._isWebGL2 = rhi.isWebGL2;
34315
- this.bind();
34316
- if (data) {
34317
- gl.bufferData(glBindTarget, data, glBufferUsage);
34318
- } else {
34319
- gl.bufferData(glBindTarget, byteLength, glBufferUsage);
34320
- }
34321
- gl.bindBuffer(glBindTarget, null);
34322
- };
34323
- var _proto = GLBuffer.prototype;
34324
- _proto.bind = function bind() {
34325
- this._gl.bindBuffer(this._glBindTarget, this._glBuffer);
34326
- };
34327
- _proto.setData = function setData(byteLength, data, bufferByteOffset, dataOffset, dataLength, options) {
34328
- var gl = this._gl;
34329
- var glBindTarget = this._glBindTarget;
34330
- this.bind();
34331
- if (options === miniprogram$1$1.SetDataOptions.Discard) {
34332
- gl.bufferData(glBindTarget, byteLength, this._glBufferUsage);
34333
- }
34334
- // TypeArray is BYTES_PER_ELEMENT, unTypeArray is 1
34335
- var byteSize = data.BYTES_PER_ELEMENT || 1;
34336
- var dataByteLength = dataLength ? byteSize * dataLength : data.byteLength;
34337
- if (dataOffset !== 0 || dataByteLength < data.byteLength) {
34338
- var isArrayBufferView = data.byteOffset !== undefined;
34339
- if (this._isWebGL2 && isArrayBufferView) {
34340
- gl.bufferSubData(glBindTarget, bufferByteOffset, data, dataOffset, dataByteLength / byteSize);
34341
- } else {
34342
- var subData = new Uint8Array(isArrayBufferView ? data.buffer : data, dataOffset * byteSize, dataByteLength);
34343
- gl.bufferSubData(glBindTarget, bufferByteOffset, subData);
34344
- }
34345
- } else {
34346
- gl.bufferSubData(glBindTarget, bufferByteOffset, data);
34347
- }
34348
- gl.bindBuffer(glBindTarget, null);
34349
- };
34350
- _proto.getData = function getData(data, bufferByteOffset, dataOffset, dataLength) {
34351
- if (this._isWebGL2) {
34352
- var gl = this._gl;
34353
- this.bind();
34354
- gl.getBufferSubData(this._glBindTarget, bufferByteOffset, data, dataOffset, dataLength);
34355
- } else {
34356
- throw "Buffer is write-only on WebGL1.0 platforms.";
34357
- }
34358
- };
34359
- _proto.resize = function resize(byteLength) {
34360
- this.bind();
34361
- this._gl.bufferData(this._glBindTarget, byteLength, this._glBufferUsage);
34362
- };
34363
- _proto.destroy = function destroy() {
34364
- this._gl.deleteBuffer(this._glBuffer);
34365
- this._gl = null;
34366
- this._glBuffer = null;
34367
- };
34368
- _proto._getGLBufferUsage = function _getGLBufferUsage(gl, bufferUsage) {
34369
- switch(bufferUsage){
34370
- case miniprogram$1$1.BufferUsage.Static:
34371
- return gl.STATIC_DRAW;
34372
- case miniprogram$1$1.BufferUsage.Dynamic:
34373
- return gl.DYNAMIC_DRAW;
34374
- case miniprogram$1$1.BufferUsage.Stream:
34375
- return gl.STREAM_DRAW;
34376
- }
34377
- };
34378
- return GLBuffer;
34379
- }();
34380
34273
  /**
34381
34274
  * GL capability.
34382
34275
  */ var GLCapability = /*#__PURE__*/ function() {
@@ -34639,8 +34532,8 @@ var GLBuffer = /*#__PURE__*/ function() {
34639
34532
  if (useVao) {
34640
34533
  gl.drawElements(topology, count, _glIndexType, start * _glIndexByteCount);
34641
34534
  } else {
34642
- var _glBuffer = _indexBufferBinding.buffer._platformBuffer._glBuffer;
34643
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _glBuffer);
34535
+ var _nativeBuffer = _indexBufferBinding.buffer._nativeBuffer;
34536
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _nativeBuffer);
34644
34537
  gl.drawElements(topology, count, _glIndexType, start * _glIndexByteCount);
34645
34538
  gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
34646
34539
  }
@@ -34653,8 +34546,8 @@ var GLBuffer = /*#__PURE__*/ function() {
34653
34546
  if (useVao) {
34654
34547
  gl.drawElementsInstanced(topology, count, _glIndexType, start * _glIndexByteCount, _instanceCount);
34655
34548
  } else {
34656
- var _glBuffer1 = _indexBufferBinding.buffer._platformBuffer._glBuffer;
34657
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _glBuffer1);
34549
+ var _nativeBuffer1 = _indexBufferBinding.buffer._nativeBuffer;
34550
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _nativeBuffer1);
34658
34551
  gl.drawElementsInstanced(topology, count, _glIndexType, start * _glIndexByteCount, _instanceCount);
34659
34552
  gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
34660
34553
  }
@@ -34694,7 +34587,7 @@ var GLBuffer = /*#__PURE__*/ function() {
34694
34587
  var element = attributes[name];
34695
34588
  if (element) {
34696
34589
  var _vertexBufferBindings_element_bindingIndex = vertexBufferBindings[element.bindingIndex], buffer = _vertexBufferBindings_element_bindingIndex.buffer, stride = _vertexBufferBindings_element_bindingIndex.stride;
34697
- vbo = buffer._platformBuffer._glBuffer;
34590
+ vbo = buffer._nativeBuffer;
34698
34591
  // prevent binding the vbo which already bound at the last loop, e.g. a buffer with multiple attributes.
34699
34592
  if (lastBoundVbo !== vbo) {
34700
34593
  lastBoundVbo = vbo;
@@ -34726,7 +34619,7 @@ var GLBuffer = /*#__PURE__*/ function() {
34726
34619
  // @ts-ignore
34727
34620
  var _indexBufferBinding = this._primitive._indexBufferBinding;
34728
34621
  if (_indexBufferBinding) {
34729
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _indexBufferBinding.buffer._platformBuffer._glBuffer);
34622
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _indexBufferBinding.buffer._nativeBuffer);
34730
34623
  }
34731
34624
  this._bindBufferAndAttrib(shaderProgram);
34732
34625
  /** unbind */ gl.bindVertexArray(null);
@@ -35783,21 +35676,23 @@ exports.WebGLMode = void 0;
35783
35676
  WebGLMode[WebGLMode[/** WebGL1.0, */ "WebGL1"] = 2] = "WebGL1";
35784
35677
  })(exports.WebGLMode || (exports.WebGLMode = {}));
35785
35678
  /**
35786
- * WebGL graphic device, including WebGL1.0 and WebGL2.0.
35787
- */ var WebGLGraphicDevice = /*#__PURE__*/ function() {
35788
- var WebGLGraphicDevice = function WebGLGraphicDevice(initializeOptions) {
35679
+ * WebGL renderer, including WebGL1.0 and WebGL2.0.
35680
+ */ var WebGLRenderer = /*#__PURE__*/ function() {
35681
+ var WebGLRenderer = function WebGLRenderer(initializeOptions) {
35789
35682
  if (initializeOptions === void 0) initializeOptions = {};
35790
- /** @internal */ this._readFrameBuffer = null;
35791
35683
  /** @internal */ this._enableGlobalDepthBias = false;
35792
35684
  this._activeTextures = new Array(32);
35685
+ // cache value
35793
35686
  this._lastViewport = new miniprogram$1.Vector4(null, null, null, null);
35794
35687
  this._lastScissor = new miniprogram$1.Vector4(null, null, null, null);
35795
35688
  this._lastClearColor = new miniprogram$1.Color(null, null, null, null);
35796
35689
  this._scissorEnable = false;
35797
35690
  var options = _extends({
35798
35691
  webGLMode: 0,
35692
+ alpha: false,
35799
35693
  stencil: true,
35800
- _forceFlush: false
35694
+ _forceFlush: false,
35695
+ _maxAllowSkinUniformVectorCount: 256
35801
35696
  }, initializeOptions);
35802
35697
  if (miniprogram$1$1.SystemInfo.platform === miniprogram$1$1.Platform.IPhone || miniprogram$1$1.SystemInfo.platform === miniprogram$1$1.Platform.IPad) {
35803
35698
  var version = miniprogram$1$1.SystemInfo.operatingSystem.match(/(\d+).?(\d+)?.?(\d+)?/);
@@ -35810,20 +35705,12 @@ exports.WebGLMode = void 0;
35810
35705
  }
35811
35706
  }
35812
35707
  this._options = options;
35813
- this._onWebGLContextLost = this._onWebGLContextLost.bind(this);
35814
- this._onWebGLContextRestored = this._onWebGLContextRestored.bind(this);
35815
35708
  };
35816
- var _proto = WebGLGraphicDevice.prototype;
35817
- _proto.init = function init(canvas, onDeviceLost, onDeviceRestored) {
35709
+ var _proto = WebGLRenderer.prototype;
35710
+ _proto.init = function init(canvas) {
35818
35711
  var options = this._options;
35819
- var webCanvas = canvas._webCanvas;
35712
+ var webCanvas = this._webCanvas = canvas._webCanvas;
35820
35713
  var webGLMode = options.webGLMode;
35821
- this._onDeviceLost = onDeviceLost;
35822
- this._onDeviceRestored = onDeviceRestored;
35823
- webCanvas.addEventListener("webglcontextlost", this._onWebGLContextLost, false);
35824
- webCanvas.addEventListener("webglcontextrestored", this._onWebGLContextRestored, false);
35825
- webCanvas.addEventListener("webglcontextcreationerror", this._onContextCreationError, false);
35826
- this._webCanvas = webCanvas;
35827
35714
  var gl;
35828
35715
  if (webGLMode == 0 || webGLMode == 1) {
35829
35716
  gl = webCanvas.getContext("webgl2", options);
@@ -35849,7 +35736,16 @@ exports.WebGLMode = void 0;
35849
35736
  throw new Error("Get GL Context FAILED.");
35850
35737
  }
35851
35738
  this._gl = gl;
35852
- this._initGLState(gl);
35739
+ this._activeTextureID = gl.TEXTURE0;
35740
+ this._renderStates = new GLRenderStates(gl);
35741
+ this._extensions = new GLExtensions(this);
35742
+ this._capability = new GLCapability(this);
35743
+ // Make sure the active texture in gl context is on default, because gl context may be used in other webgl renderer.
35744
+ gl.activeTexture(gl.TEXTURE0);
35745
+ var debugRenderInfo = gl.getExtension("WEBGL_debug_renderer_info");
35746
+ if (debugRenderInfo != null) {
35747
+ this._renderer = gl.getParameter(debugRenderInfo.UNMASKED_RENDERER_WEBGL);
35748
+ }
35853
35749
  };
35854
35750
  _proto.createPlatformPrimitive = function createPlatformPrimitive(primitive) {
35855
35751
  return new GLPrimitive(this, primitive);
@@ -35866,10 +35762,6 @@ exports.WebGLMode = void 0;
35866
35762
  _proto.createPlatformRenderTarget = function createPlatformRenderTarget(target) {
35867
35763
  return new GLRenderTarget(this, target);
35868
35764
  };
35869
- _proto.createPlatformBuffer = function createPlatformBuffer(type, byteLength, bufferUsage, data) {
35870
- if (bufferUsage === void 0) bufferUsage = miniprogram$1$1.BufferUsage.Static;
35871
- return new GLBuffer(this, type, byteLength, bufferUsage, data);
35872
- };
35873
35765
  _proto.requireExtension = function requireExtension(ext) {
35874
35766
  return this._extensions.requireExtension(ext);
35875
35767
  };
@@ -35997,57 +35889,8 @@ exports.WebGLMode = void 0;
35997
35889
  _proto.flush = function flush() {
35998
35890
  this._gl.flush();
35999
35891
  };
36000
- _proto.forceLoseDevice = function forceLoseDevice() {
36001
- var extension = this.requireExtension(miniprogram$1$1.GLCapabilityType.WEBGL_lose_context);
36002
- extension.loseContext();
36003
- };
36004
- _proto.forceRestoreDevice = function forceRestoreDevice() {
36005
- var extension = this.requireExtension(miniprogram$1$1.GLCapabilityType.WEBGL_lose_context);
36006
- extension.restoreContext();
36007
- };
36008
- _proto.resetState = function resetState() {
36009
- this._readFrameBuffer = null;
36010
- this._enableGlobalDepthBias = false;
36011
- this._currentBindShaderProgram = null;
36012
- var activeTextures = this._activeTextures;
36013
- for(var i = 0, n = activeTextures.length; i < n; i++){
36014
- activeTextures[i] = null;
36015
- }
36016
- this._lastViewport.set(null, null, null, null);
36017
- this._lastScissor.set(null, null, null, null);
36018
- this._lastClearColor.set(null, null, null, null);
36019
- this._scissorEnable = false;
36020
- this._initGLState(this._gl);
36021
- };
36022
- _proto._initGLState = function _initGLState(gl) {
36023
- this._activeTextureID = gl.TEXTURE0;
36024
- this._renderStates = new GLRenderStates(gl);
36025
- this._extensions = new GLExtensions(this);
36026
- this._capability = new GLCapability(this);
36027
- // Make sure the active texture in gl context is on default, because gl context may be used in other webgl renderer.
36028
- gl.activeTexture(gl.TEXTURE0);
36029
- var debugRenderInfo = gl.getExtension("WEBGL_debug_renderer_info");
36030
- if (debugRenderInfo != null) {
36031
- this._renderer = gl.getParameter(debugRenderInfo.UNMASKED_RENDERER_WEBGL);
36032
- }
36033
- };
36034
- _proto.destroy = function destroy() {
36035
- var webCanvas = this._webCanvas;
36036
- webCanvas.removeEventListener("webglcontextcreationerror", this._onContextCreationError, false);
36037
- webCanvas.removeEventListener("webglcontextlost", this._onWebGLContextLost, false);
36038
- webCanvas.removeEventListener("webglcontextrestored", this._onWebGLContextRestored, false);
36039
- };
36040
- _proto._onContextCreationError = function _onContextCreationError(event) {
36041
- console.error("WebGLRenderer: WebGL context could not be created. Reason: ", event.statusMessage);
36042
- };
36043
- _proto._onWebGLContextLost = function _onWebGLContextLost(event) {
36044
- event.preventDefault();
36045
- this._onDeviceLost();
36046
- };
36047
- _proto._onWebGLContextRestored = function _onWebGLContextRestored(event) {
36048
- this._onDeviceRestored();
36049
- };
36050
- _create_class(WebGLGraphicDevice, [
35892
+ _proto.destroy = function destroy() {};
35893
+ _create_class(WebGLRenderer, [
36051
35894
  {
36052
35895
  key: "isWebGL2",
36053
35896
  get: function get() {
@@ -36088,11 +35931,32 @@ exports.WebGLMode = void 0;
36088
35931
  }
36089
35932
  }
36090
35933
  ]);
36091
- return WebGLGraphicDevice;
35934
+ return WebGLRenderer;
36092
35935
  }();
35936
+ /**
35937
+ * WebGL platform engine,support includes WebGL1.0 and WebGL2.0.
35938
+ */ var WebGLEngine = /*#__PURE__*/ function(Engine) {
35939
+ var WebGLEngine = function WebGLEngine(canvas, webGLRendererOptions) {
35940
+ var webCanvas = new WebCanvas(typeof canvas === "string" ? engineMiniprogramAdapter.document.getElementById(canvas) : canvas);
35941
+ var hardwareRenderer = new WebGLRenderer(webGLRendererOptions);
35942
+ return Engine.call(this, webCanvas, hardwareRenderer);
35943
+ };
35944
+ _inherits(WebGLEngine, Engine);
35945
+ _create_class(WebGLEngine, [
35946
+ {
35947
+ key: "canvas",
35948
+ get: /**
35949
+ * Web canvas.
35950
+ */ function get() {
35951
+ return this._canvas;
35952
+ }
35953
+ }
35954
+ ]);
35955
+ return WebGLEngine;
35956
+ }(miniprogram$1$1.Engine);
36093
35957
  exports.WebCanvas = WebCanvas;
36094
35958
  exports.WebGLEngine = WebGLEngine;
36095
- exports.WebGLGraphicDevice = WebGLGraphicDevice;
35959
+ exports.WebGLRenderer = WebGLRenderer;
36096
35960
 
36097
35961
  var miniprogram$3 = /*#__PURE__*/Object.freeze({
36098
35962
  __proto__: null
@@ -36133,7 +35997,7 @@ function _interopNamespace(e) {
36133
35997
  }
36134
35998
  var CoreObjects__namespace = /*#__PURE__*/ _interopNamespace(CoreObjects);
36135
35999
  //@ts-ignore
36136
- var version = "0.0.0-experimental-0.9-plus.3";
36000
+ var version = "0.0.0-experimental-0.9-plus.4";
36137
36001
  console.log("Galacean engine version: " + version);
36138
36002
  for(var key in CoreObjects__namespace){
36139
36003
  CoreObjects.Loader.registerClass(key, CoreObjects__namespace[key]);