Переглянути джерело

Merge remote-tracking branch 'BabylonJS/master' into viewer-mesh-normalization

# Conflicts:
#	dist/preview release/what's new.md
Raanan Weber 7 роки тому
батько
коміт
0066a50161
35 змінених файлів з 35603 додано та 28649 видалено
  1. 13933 12871
      Playground/babylon.d.txt
  2. 3 0
      Tools/Gulp/config.json
  3. 5 1
      Tools/Gulp/gulpfile.js
  4. 51 51
      Viewer/dist/viewer.js
  5. 51 51
      Viewer/dist/viewer.min.js
  6. 10874 9850
      dist/preview release/babylon.d.ts
  7. 48 48
      dist/preview release/babylon.js
  8. 920 25
      dist/preview release/babylon.max.js
  9. 49 49
      dist/preview release/babylon.worker.js
  10. 6481 5457
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts
  11. 49 49
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js
  12. 920 25
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js
  13. 920 25
      dist/preview release/customConfigurations/minimalGLTFViewer/es6.js
  14. 920 25
      dist/preview release/es6.js
  15. 3 3
      dist/preview release/gui/babylon.gui.min.js
  16. 4 4
      dist/preview release/inspector/babylon.inspector.bundle.js
  17. 3 3
      dist/preview release/inspector/babylon.inspector.min.js
  18. 2 2
      dist/preview release/loaders/babylon.glTF1FileLoader.min.js
  19. 2 2
      dist/preview release/loaders/babylon.glTF2FileLoader.min.js
  20. 3 3
      dist/preview release/loaders/babylon.glTFFileLoader.min.js
  21. 1 1
      dist/preview release/loaders/babylon.objFileLoader.min.js
  22. 3 3
      dist/preview release/loaders/babylonjs.loaders.min.js
  23. 1 1
      dist/preview release/materialsLibrary/babylon.customMaterial.min.js
  24. 1 1
      dist/preview release/materialsLibrary/babylon.shadowOnlyMaterial.min.js
  25. 1 1
      dist/preview release/materialsLibrary/babylon.waterMaterial.min.js
  26. 3 3
      dist/preview release/materialsLibrary/babylonjs.materials.min.js
  27. 1 1
      dist/preview release/postProcessesLibrary/babylon.asciiArtPostProcess.min.js
  28. 1 1
      dist/preview release/postProcessesLibrary/babylon.digitalRainPostProcess.min.js
  29. 1 1
      dist/preview release/postProcessesLibrary/babylonjs.postProcess.min.js
  30. 249 0
      dist/preview release/serializers/babylonjs.serializers.module.d.ts
  31. 51 51
      dist/preview release/viewer/babylon.viewer.js
  32. 1 0
      dist/preview release/what's new.md
  33. 0 32
      src/Materials/babylon.material.ts
  34. 6 0
      src/Particles/babylon.solidParticle.ts
  35. 42 9
      src/Particles/babylon.solidParticleSystem.ts

Різницю між файлами не показано, бо вона завелика
+ 13933 - 12871
Playground/babylon.d.txt


+ 3 - 0
Tools/Gulp/config.json

@@ -1524,6 +1524,9 @@
             "distOutputDirectory": "/serializers/",
             "buildAsModule": true,
             "moduleName": "babylonjs-serializers",
+            "extraDeclarations": [
+                "../../dist/babylon.glTF2Interface.d.ts"
+            ],
             "outputFilename": "babylonjs.serializers",
             "moduleDeclaration": "BJSSerializers",
             "extendsRoot": true

+ 5 - 1
Tools/Gulp/gulpfile.js

@@ -325,7 +325,9 @@ var buildExternalLibraries = function (settings) {
             let dtsFiles = files.map(function (filename) {
                 return filename.replace(".js", ".d.ts");
             });
-
+            if (settings.build.extraDeclarations) {
+                settings.build.extraDeclarations.forEach(file => { dtsFiles.unshift(file) })
+            }
             let dtsTask = gulp.src(dtsFiles)
                 .pipe(concat(settings.build.outputFilename + ".module.d.ts"))
                 .pipe(replace(referenceSearchRegex, ""))
@@ -405,6 +407,8 @@ var buildExternalLibrary = function (library, settings, watch) {
             .pipe(gulp.dest(outputDirectory));
         /*}*/
 
+
+
         var dts = tsProcess.dts
             .pipe(concat(library.output))
             .pipe(replace(referenceSearchRegex, ""))

Різницю між файлами не показано, бо вона завелика
+ 51 - 51
Viewer/dist/viewer.js


Різницю між файлами не показано, бо вона завелика
+ 51 - 51
Viewer/dist/viewer.min.js


Різницю між файлами не показано, бо вона завелика
+ 10874 - 9850
dist/preview release/babylon.d.ts


Різницю між файлами не показано, бо вона завелика
+ 48 - 48
dist/preview release/babylon.js


Різницю між файлами не показано, бо вона завелика
+ 920 - 25
dist/preview release/babylon.max.js


Різницю між файлами не показано, бо вона завелика
+ 49 - 49
dist/preview release/babylon.worker.js


Різницю між файлами не показано, бо вона завелика
+ 6481 - 5457
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


Різницю між файлами не показано, бо вона завелика
+ 49 - 49
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


Різницю між файлами не показано, бо вона завелика
+ 920 - 25
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js


Різницю між файлами не показано, бо вона завелика
+ 920 - 25
dist/preview release/customConfigurations/minimalGLTFViewer/es6.js


Різницю між файлами не показано, бо вона завелика
+ 920 - 25
dist/preview release/es6.js


Різницю між файлами не показано, бо вона завелика
+ 3 - 3
dist/preview release/gui/babylon.gui.min.js


Різницю між файлами не показано, бо вона завелика
+ 4 - 4
dist/preview release/inspector/babylon.inspector.bundle.js


Різницю між файлами не показано, бо вона завелика
+ 3 - 3
dist/preview release/inspector/babylon.inspector.min.js


Різницю між файлами не показано, бо вона завелика
+ 2 - 2
dist/preview release/loaders/babylon.glTF1FileLoader.min.js


Різницю між файлами не показано, бо вона завелика
+ 2 - 2
dist/preview release/loaders/babylon.glTF2FileLoader.min.js


Різницю між файлами не показано, бо вона завелика
+ 3 - 3
dist/preview release/loaders/babylon.glTFFileLoader.min.js


Різницю між файлами не показано, бо вона завелика
+ 1 - 1
dist/preview release/loaders/babylon.objFileLoader.min.js


Різницю між файлами не показано, бо вона завелика
+ 3 - 3
dist/preview release/loaders/babylonjs.loaders.min.js


Різницю між файлами не показано, бо вона завелика
+ 1 - 1
dist/preview release/materialsLibrary/babylon.customMaterial.min.js


Різницю між файлами не показано, бо вона завелика
+ 1 - 1
dist/preview release/materialsLibrary/babylon.shadowOnlyMaterial.min.js


Різницю між файлами не показано, бо вона завелика
+ 1 - 1
dist/preview release/materialsLibrary/babylon.waterMaterial.min.js


Різницю між файлами не показано, бо вона завелика
+ 3 - 3
dist/preview release/materialsLibrary/babylonjs.materials.min.js


Різницю між файлами не показано, бо вона завелика
+ 1 - 1
dist/preview release/postProcessesLibrary/babylon.asciiArtPostProcess.min.js


Різницю між файлами не показано, бо вона завелика
+ 1 - 1
dist/preview release/postProcessesLibrary/babylon.digitalRainPostProcess.min.js


Різницю між файлами не показано, бо вона завелика
+ 1 - 1
dist/preview release/postProcessesLibrary/babylonjs.postProcess.min.js


+ 249 - 0
dist/preview release/serializers/babylonjs.serializers.module.d.ts

@@ -4,6 +4,255 @@
 declare module 'babylonjs-serializers' { 
     export = BABYLON; 
 }
+declare module BABYLON.GLTF2 {
+    const enum AccessorComponentType {
+        BYTE = 5120,
+        UNSIGNED_BYTE = 5121,
+        SHORT = 5122,
+        UNSIGNED_SHORT = 5123,
+        UNSIGNED_INT = 5125,
+        FLOAT = 5126,
+    }
+    const enum AccessorType {
+        SCALAR = "SCALAR",
+        VEC2 = "VEC2",
+        VEC3 = "VEC3",
+        VEC4 = "VEC4",
+        MAT2 = "MAT2",
+        MAT3 = "MAT3",
+        MAT4 = "MAT4",
+    }
+    const enum AnimationChannelTargetPath {
+        TRANSLATION = "translation",
+        ROTATION = "rotation",
+        SCALE = "scale",
+        WEIGHTS = "weights",
+    }
+    const enum AnimationInterpolation {
+        LINEAR = "LINEAR",
+        STEP = "STEP",
+        CUBICSPLINE = "CUBICSPLINE",
+    }
+    const enum CameraType {
+        PERSPECTIVE = "perspective",
+        ORTHOGRAPHIC = "orthographic",
+    }
+    const enum ImageMimeType {
+        JPEG = "image/jpeg",
+        PNG = "image/png",
+    }
+    const enum MaterialAlphaMode {
+        OPAQUE = "OPAQUE",
+        MASK = "MASK",
+        BLEND = "BLEND",
+    }
+    const enum MeshPrimitiveMode {
+        POINTS = 0,
+        LINES = 1,
+        LINE_LOOP = 2,
+        LINE_STRIP = 3,
+        TRIANGLES = 4,
+        TRIANGLE_STRIP = 5,
+        TRIANGLE_FAN = 6,
+    }
+    const enum TextureMagFilter {
+        NEAREST = 9728,
+        LINEAR = 9729,
+    }
+    const enum TextureMinFilter {
+        NEAREST = 9728,
+        LINEAR = 9729,
+        NEAREST_MIPMAP_NEAREST = 9984,
+        LINEAR_MIPMAP_NEAREST = 9985,
+        NEAREST_MIPMAP_LINEAR = 9986,
+        LINEAR_MIPMAP_LINEAR = 9987,
+    }
+    const enum TextureWrapMode {
+        CLAMP_TO_EDGE = 33071,
+        MIRRORED_REPEAT = 33648,
+        REPEAT = 10497,
+    }
+    interface IProperty {
+        extensions?: {
+            [key: string]: any;
+        };
+        extras?: any;
+    }
+    interface IChildRootProperty extends IProperty {
+        name?: string;
+    }
+    interface IAccessorSparseIndices extends IProperty {
+        bufferView: number;
+        byteOffset?: number;
+        componentType: AccessorComponentType;
+    }
+    interface IAccessorSparseValues extends IProperty {
+        bufferView: number;
+        byteOffset?: number;
+    }
+    interface IAccessorSparse extends IProperty {
+        count: number;
+        indices: IAccessorSparseIndices;
+        values: IAccessorSparseValues;
+    }
+    interface IAccessor extends IChildRootProperty {
+        bufferView?: number;
+        byteOffset?: number;
+        componentType: AccessorComponentType;
+        normalized?: boolean;
+        count: number;
+        type: AccessorType;
+        max?: number[];
+        min?: number[];
+        sparse?: IAccessorSparse;
+    }
+    interface IAnimationChannel extends IProperty {
+        sampler: number;
+        target: IAnimationChannelTarget;
+    }
+    interface IAnimationChannelTarget extends IProperty {
+        node: number;
+        path: AnimationChannelTargetPath;
+    }
+    interface IAnimationSampler extends IProperty {
+        input: number;
+        interpolation?: AnimationInterpolation;
+        output: number;
+    }
+    interface IAnimation extends IChildRootProperty {
+        channels: IAnimationChannel[];
+        samplers: IAnimationSampler[];
+    }
+    interface IAsset extends IChildRootProperty {
+        copyright?: string;
+        generator?: string;
+        version: string;
+        minVersion?: string;
+    }
+    interface IBuffer extends IChildRootProperty {
+        uri?: string;
+        byteLength: number;
+    }
+    interface IBufferView extends IChildRootProperty {
+        buffer: number;
+        byteOffset?: number;
+        byteLength: number;
+        byteStride?: number;
+    }
+    interface ICameraOrthographic extends IProperty {
+        xmag: number;
+        ymag: number;
+        zfar: number;
+        znear: number;
+    }
+    interface ICameraPerspective extends IProperty {
+        aspectRatio: number;
+        yfov: number;
+        zfar: number;
+        znear: number;
+    }
+    interface ICamera extends IChildRootProperty {
+        orthographic?: ICameraOrthographic;
+        perspective?: ICameraPerspective;
+        type: CameraType;
+    }
+    interface IImage extends IChildRootProperty {
+        uri?: string;
+        mimeType?: ImageMimeType;
+        bufferView?: number;
+    }
+    interface IMaterialNormalTextureInfo extends ITextureInfo {
+        scale?: number;
+    }
+    interface IMaterialOcclusionTextureInfo extends ITextureInfo {
+        strength?: number;
+    }
+    interface IMaterialPbrMetallicRoughness {
+        baseColorFactor?: number[];
+        baseColorTexture?: ITextureInfo;
+        metallicFactor?: number;
+        roughnessFactor?: number;
+        metallicRoughnessTexture?: ITextureInfo;
+    }
+    interface IMaterial extends IChildRootProperty {
+        pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
+        normalTexture?: IMaterialNormalTextureInfo;
+        occlusionTexture?: IMaterialOcclusionTextureInfo;
+        emissiveTexture?: ITextureInfo;
+        emissiveFactor?: number[];
+        alphaMode?: MaterialAlphaMode;
+        alphaCutoff?: number;
+        doubleSided?: boolean;
+    }
+    interface IMeshPrimitive extends IProperty {
+        attributes: {
+            [name: string]: number;
+        };
+        indices?: number;
+        material?: number;
+        mode?: MeshPrimitiveMode;
+        targets?: {
+            [name: string]: number;
+        }[];
+    }
+    interface IMesh extends IChildRootProperty {
+        primitives: IMeshPrimitive[];
+        weights?: number[];
+    }
+    interface INode extends IChildRootProperty {
+        camera?: number;
+        children?: number[];
+        skin?: number;
+        matrix?: number[];
+        mesh?: number;
+        rotation?: number[];
+        scale?: number[];
+        translation?: number[];
+        weights?: number[];
+    }
+    interface ISampler extends IChildRootProperty {
+        magFilter?: TextureMagFilter;
+        minFilter?: TextureMinFilter;
+        wrapS?: TextureWrapMode;
+        wrapT?: TextureWrapMode;
+    }
+    interface IScene extends IChildRootProperty {
+        nodes: number[];
+    }
+    interface ISkin extends IChildRootProperty {
+        inverseBindMatrices?: number;
+        skeleton?: number;
+        joints: number[];
+    }
+    interface ITexture extends IChildRootProperty {
+        sampler?: number;
+        source: number;
+    }
+    interface ITextureInfo {
+        index: number;
+        texCoord?: number;
+    }
+    interface IGLTF extends IProperty {
+        accessors?: IAccessor[];
+        animations?: IAnimation[];
+        asset: IAsset;
+        buffers?: IBuffer[];
+        bufferViews?: IBufferView[];
+        cameras?: ICamera[];
+        extensionsUsed?: string[];
+        extensionsRequired?: string[];
+        images?: IImage[];
+        materials?: IMaterial[];
+        meshes?: IMesh[];
+        nodes?: INode[];
+        samplers?: ISampler[];
+        scene?: number;
+        scenes?: IScene[];
+        skins?: ISkin[];
+        textures?: ITexture[];
+    }
+}
+
 
 declare module BABYLON {
     class OBJExport {

Різницю між файлами не показано, бо вона завелика
+ 51 - 51
dist/preview release/viewer/babylon.viewer.js


+ 1 - 0
dist/preview release/what's new.md

@@ -48,6 +48,7 @@
 - KeepAssets class and AssetContainer.moveAllFromScene ([HoloLite](http://www.html5gamedevs.com/profile/28694-hololite/), [trevordev](https://github.com/trevordev))
 - (Viewer) It is now possible to update parts of the configuration without rcreating the objects. ([RaananW](https://github.com/RaananW))
 - (Viewer) Model can be normalized using configuration. ([RaananW](https://github.com/RaananW))
+- (Gulp) extra/external declarations can be prepended to final NPM declarations during build. ([RaananW](https://github.com/RaananW))
 
 ## Bug fixes
 - `setPivotMatrix` ws not setting pivot correctly. This is now fixed. We also introduced a new `setPreTransformMatrix` to reproduce the sometimes needed behavior of the previous `setPivotMatrix` function ([deltakosh](https://github.com/deltakosh))

+ 0 - 32
src/Materials/babylon.material.ts

@@ -22,7 +22,6 @@
 
         /**
          * Specifies if the material needs to be re-calculated.
-         * @returns - Boolean indicating if the material is dirty or not.
          */
         public get isDirty(): boolean {
             return this._isDirty;
@@ -221,7 +220,6 @@
 
         /**
          * Returns the triangle fill mode.
-         * @returns - Number indicating the triangle fill mode.
          */
         public static get TriangleFillMode(): number {
             return Material._TriangleFillMode;
@@ -229,7 +227,6 @@
 
         /**
          * Returns the wireframe mode.
-         * @returns - Number indicating the wireframe mode.
          */
         public static get WireFrameFillMode(): number {
             return Material._WireFrameFillMode;
@@ -237,7 +234,6 @@
 
         /**
          * Returns the point fill mode.
-         * @returns - Number indicating the point fill mode.
          */
         public static get PointFillMode(): number {
             return Material._PointFillMode;
@@ -245,7 +241,6 @@
 
         /**
          * Returns the point list draw mode.
-         * @returns - Number indicating the point list draw mode.
          */
         public static get PointListDrawMode(): number {
             return Material._PointListDrawMode;
@@ -253,7 +248,6 @@
 
         /**
          * Returns the line list draw mode.
-         * @returns - Number indicating the line list draw mode.
          */
         public static get LineListDrawMode(): number {
             return Material._LineListDrawMode;
@@ -261,7 +255,6 @@
 
         /**
          * Returns the line loop draw mode.
-         * @returns - Number indicating the line loop draw mode.
          */
         public static get LineLoopDrawMode(): number {
             return Material._LineLoopDrawMode;
@@ -269,7 +262,6 @@
 
         /**
          * Returns the line strip draw mode.
-         * @returns - Number indicating the line strip draw mode.
          */
         public static get LineStripDrawMode(): number {
             return Material._LineStripDrawMode;
@@ -277,7 +269,6 @@
 
         /**
          * Returns the triangle strip draw mode.
-         * @returns - Number indicating the triangle strip draw mode.
          */
         public static get TriangleStripDrawMode(): number {
             return Material._TriangleStripDrawMode;
@@ -285,7 +276,6 @@
 
         /**
          * Returns the triangle fan draw mode.
-         * @returns - Number indicating the triangle fan draw mode.
          */
         public static get TriangleFanDrawMode(): number {
             return Material._TriangleFanDrawMode;
@@ -303,7 +293,6 @@
 
         /**
          * Returns the clock-wise side orientation.
-         * @returns - Number indicating the clock-wise side orientation.
          */
         public static get ClockWiseSideOrientation(): number {
             return Material._ClockWiseSideOrientation;
@@ -311,7 +300,6 @@
 
         /**
          * Returns the counter clock-wise side orientation.
-         * @returns - Number indicating the counter clock-wise side orientation.
          */
         public static get CounterClockWiseSideOrientation(): number {
             return Material._CounterClockWiseSideOrientation;
@@ -344,7 +332,6 @@
 
         /**
          * Returns the dirty texture flag value.
-         * @returns - Number for the dirty texture flag value.
          */
         public static get TextureDirtyFlag(): number {
             return Material._TextureDirtyFlag;
@@ -352,7 +339,6 @@
 
         /**
          * Returns the dirty light flag value.
-         * @returns - Number for the dirty light flag value.
          */
         public static get LightDirtyFlag(): number {
             return Material._LightDirtyFlag;
@@ -360,7 +346,6 @@
 
         /**
          * Returns the dirty fresnel flag value.
-         * @returns - Number for the dirsty fresnel flag value.
          */
         public static get FresnelDirtyFlag(): number {
             return Material._FresnelDirtyFlag;
@@ -368,7 +353,6 @@
 
         /**
          * Returns the dirty attributes flag value.
-         * @returns - Number for the dirty attribute flag value.
          */
         public static get AttributesDirtyFlag(): number {
             return Material._AttributesDirtyFlag;
@@ -376,7 +360,6 @@
 
         /**
          * Returns the dirty misc flag value.
-         * @returns - Number for the dirty misc flag value.
          */
         public static get MiscDirtyFlag(): number {
             return Material._MiscDirtyFlag;
@@ -431,7 +414,6 @@
 
         /**
          * Gets the alpha value of the material.
-         * @returns - Number of the alpha value.
          */
         public get alpha(): number {
             return this._alpha;
@@ -445,7 +427,6 @@
 
         /**
          * Sets the back-face culling state.
-         * @param value - Booleean specifying if back face culling should be enabled.
          */
         public set backFaceCulling(value: boolean) {
             if (this._backFaceCulling === value) {
@@ -457,7 +438,6 @@
 
         /**
          * Gets the back-face culling state.
-         * @returns - Boolean specifiying if back face culling is enabled.
          */
         public get backFaceCulling(): boolean {
             return this._backFaceCulling;
@@ -557,7 +537,6 @@
 
         /**
          * Sets the value of the alpha mode.
-         * @param value - Number representing the alpha mode.
          */
         public set alphaMode(value: number) {
             if (this._alphaMode === value) {
@@ -569,7 +548,6 @@
 
         /**
          * Gets the value of the alpha mode.
-         * @returns - Number of the alpha mode.
          */
         public get alphaMode(): number {
             return this._alphaMode;
@@ -583,7 +561,6 @@
 
         /**
          * Sets the need depth pre-pass value.
-         * @param value - Boolean specifying if the depth pre-pass is needed.
          */
         public set needDepthPrePass(value: boolean) {
             if (this._needDepthPrePass === value) {
@@ -597,7 +574,6 @@
 
         /**
          * Gets the depth pre-pass value.
-         * @returns - Boolean specifying if the depth pre-pass is needed.
          */
         public get needDepthPrePass(): boolean {
             return this._needDepthPrePass;
@@ -629,7 +605,6 @@
 
         /**
          * Sets the state for enabling fog.
-         * @param value - Boolean specifying if fog should be enabled.
          */
         public set fogEnabled(value: boolean) {
             if (this._fogEnabled === value) {
@@ -641,7 +616,6 @@
 
         /**
          * Gets the value of the fog enabled state.
-         * @returns - Boolean indicating the fog enabled state.
          */
         public get fogEnabled(): boolean {
             return this._fogEnabled;
@@ -661,7 +635,6 @@
 
         /**
          * Gets a value specifying if wireframe mode is enabled.
-         * @returns - Boolean specifying if wireframe is enabled. 
          */
         @serialize()
         public get wireframe(): boolean {
@@ -670,7 +643,6 @@
 
         /**
          * Sets the state of wireframe mode.
-         * @param value - Boolean specifying if wireframe is enabled.
          */
         public set wireframe(value: boolean) {
             this._fillMode = (value ? Material.WireFrameFillMode : Material.TriangleFillMode);
@@ -678,7 +650,6 @@
 
         /**
          * Gets the value specifying if point clouds are enabled.
-         * @returns - Boolean specifying if point clouds are enabled.
          */
         @serialize()
         public get pointsCloud(): boolean {
@@ -687,7 +658,6 @@
 
         /**
          * Sets the state of point cloud mode.
-         * @param value - Boolean specifying if point clouds are enabled.
          */
         public set pointsCloud(value: boolean) {
             this._fillMode = (value ? Material.PointFillMode : Material.TriangleFillMode);
@@ -695,7 +665,6 @@
 
         /**
          * Gets the material fill mode.
-         * @returns - Number specifying the fill mode.
          */
         @serialize()
         public get fillMode(): number {
@@ -704,7 +673,6 @@
 
         /**
          * Sets the material fill mode.
-         * @param value - Number specifying the material fill mode.
          */
         public set fillMode(value: number) {
             if (this._fillMode === value) {

+ 6 - 0
src/Particles/babylon.solidParticle.ts

@@ -41,6 +41,12 @@ module BABYLON {
          */
         public pivot: Vector3 = Vector3.Zero();
         /**
+         * Must the particle be translated from its pivot point in its local space ?
+         * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.  
+         * Default : false
+         */
+        public translateFromPivot: boolean = false;
+        /**
          * Is the particle active or not ?
          */
         public alive: boolean = true;

+ 42 - 9
src/Particles/babylon.solidParticleSystem.ts

@@ -133,6 +133,7 @@
                     return (p2.sqDistance - p1.sqDistance);
                 };
             private _needs32Bits: boolean = false;
+            private _pivotBackTranslation: Vector3 = Vector3.Zero();
 
             /**
              * Creates a SPS (Solid Particle System) object.
@@ -373,6 +374,7 @@
                 this._copy.uvs.z = 1.0;
                 this._copy.uvs.w = 1.0;
                 this._copy.color = null;
+                this._copy.translateFromPivot = false;
             }
     
             // _meshBuilder : inserts the shape model in the global SPS mesh
@@ -397,6 +399,13 @@
                     this._quaternionRotationYPR();
                 }
                 this._quaternionToRotationMatrix();
+                
+                if (this._copy.translateFromPivot) {
+                    this._pivotBackTranslation.copyFromFloats(0.0, 0.0, 0.0);
+                }
+                else {
+                    this._pivotBackTranslation.copyFrom(this._copy.pivot);
+                }
     
                 for (i = 0; i < shape.length; i++) {
                     this._vertex.x = shape[i].x;
@@ -411,11 +420,13 @@
                     this._vertex.y *= this._copy.scaling.y;
                     this._vertex.z *= this._copy.scaling.z;
 
-                    this._vertex.x += this._copy.pivot.x;
-                    this._vertex.y += this._copy.pivot.y;
-                    this._vertex.z += this._copy.pivot.z;
+                    this._vertex.x -= this._copy.pivot.x;
+                    this._vertex.y -= this._copy.pivot.y;
+                    this._vertex.z -= this._copy.pivot.z;
     
                     Vector3.TransformCoordinatesToRef(this._vertex, this._rotMatrix, this._rotated);
+
+                    this._rotated.addInPlace(this._pivotBackTranslation);
                     positions.push(this._copy.position.x + this._rotated.x, this._copy.position.y + this._rotated.y, this._copy.position.z + this._rotated.z);
                     if (meshUV) {
                         uvs.push((this._copy.uvs.z - this._copy.uvs.x) * meshUV[u] + this._copy.uvs.x, (this._copy.uvs.w - this._copy.uvs.y) * meshUV[u + 1] + this._copy.uvs.y);
@@ -570,6 +581,13 @@
                     this._quaternionRotationYPR();
                 }
                 this._quaternionToRotationMatrix();
+
+                if (this._copy.translateFromPivot) {
+                    this._pivotBackTranslation.copyFromFloats(0.0, 0.0, 0.0);
+                }
+                else {
+                    this._pivotBackTranslation.copyFrom(this._copy.pivot);
+                }
     
                 this._shape = particle._model._shape;
                 for (var pt = 0; pt < this._shape.length; pt++) {
@@ -585,11 +603,12 @@
                     this._vertex.y *= this._copy.scaling.y;
                     this._vertex.z *= this._copy.scaling.z;
 
-                    this._vertex.x += this._copy.pivot.x;
-                    this._vertex.y += this._copy.pivot.y;
-                    this._vertex.z += this._copy.pivot.z;
+                    this._vertex.x -= this._copy.pivot.x;
+                    this._vertex.y -= this._copy.pivot.y;
+                    this._vertex.z -= this._copy.pivot.z;
     
                     Vector3.TransformCoordinatesToRef(this._vertex, this._rotMatrix, this._rotated);
+                    this._rotated.addInPlace(this._pivotBackTranslation);
     
                     this._positions32[particle._pos + pt * 3] = this._copy.position.x + this._rotated.x;
                     this._positions32[particle._pos + pt * 3 + 1] = this._copy.position.y + this._rotated.y;
@@ -759,6 +778,16 @@
                             this._particle._rotationMatrix[8] = this._rotMatrix.m[10];
                         }
        
+                        if (this._particle.translateFromPivot) {
+                            this._pivotBackTranslation.x = 0.0;
+                            this._pivotBackTranslation.y = 0.0;
+                            this._pivotBackTranslation.z = 0.0;
+                        }
+                        else {
+                            this._pivotBackTranslation.x = this._particle.pivot.x;
+                            this._pivotBackTranslation.y = this._particle.pivot.y;
+                            this._pivotBackTranslation.z = this._particle.pivot.z;
+                        }
                         // particle vertex loop
                         for (pt = 0; pt < this._shape.length; pt++) {
                             idx = index + pt * 3;
@@ -778,14 +807,18 @@
                             this._vertex.y *= this._particle.scaling.y;
                             this._vertex.z *= this._particle.scaling.z;
 
-                            this._vertex.x += this._particle.pivot.x;
-                            this._vertex.y += this._particle.pivot.y;
-                            this._vertex.z += this._particle.pivot.z;
+                            this._vertex.x -= this._particle.pivot.x;
+                            this._vertex.y -= this._particle.pivot.y;
+                            this._vertex.z -= this._particle.pivot.z;
     
                             this._rotated.x = this._vertex.x * this._particle._rotationMatrix[0] + this._vertex.y * this._particle._rotationMatrix[3] + this._vertex.z * this._particle._rotationMatrix[6];
                             this._rotated.y = this._vertex.x * this._particle._rotationMatrix[1] + this._vertex.y * this._particle._rotationMatrix[4] + this._vertex.z * this._particle._rotationMatrix[7];
                             this._rotated.z = this._vertex.x * this._particle._rotationMatrix[2] + this._vertex.y * this._particle._rotationMatrix[5] + this._vertex.z * this._particle._rotationMatrix[8];
     
+                            this._rotated.x += this._pivotBackTranslation.x;
+                            this._rotated.y += this._pivotBackTranslation.y;
+                            this._rotated.z += this._pivotBackTranslation.z;
+
                             this._positions32[idx] = this._particle.position.x + this._cam_axisX.x * this._rotated.x + this._cam_axisY.x * this._rotated.y + this._cam_axisZ.x * this._rotated.z;
                             this._positions32[idx + 1] = this._particle.position.y + this._cam_axisX.y * this._rotated.x + this._cam_axisY.y * this._rotated.y + this._cam_axisZ.y * this._rotated.z;
                             this._positions32[idx + 2] = this._particle.position.z + this._cam_axisX.z * this._rotated.x + this._cam_axisY.z * this._rotated.y + this._cam_axisZ.z * this._rotated.z;