BabylonJS文件格式---基於WebGL的H5 3D遊戲引擎

Babylon.js 使用JSON文件格式來描述場景.

你可以在這兒找到完整的加載器代碼:
https://github.com/BabylonJS/Babylon.js/blob/master/src/Loading/Plugins/babylon.babylonFileLoader.js

基礎類型

.babylon 文件使用下面的約定來定義基礎類型:

  • Vector3: 一個含有3個浮點數([x, y, z])的數組. 例子: [1.1, 2.2, 3.3]
  • Vector4: 一個含有4個浮點數([x, y, z, w])的數組. 例子: [1.1, 2.2, 3.3, 4.4]
  • Color3: 一個含有3個浮點數 ([r, g, b])且每個數的值大小在0和1間的數組. 例子: [0.2, 0.3, 0.5]
  • Matrix: 行優先(先按行存儲)的含有16個浮點數的數組
  • Boolean: 真或假

全局結構體

.babylon文件裏的全局結構體是下面這樣的:

{
    "autoClear": boolean,
    "clearColor": color3,
    "ambientColor": color3,
    "gravity": vector3 (通常是[0,-9,0]),
    "cameras": 相機數組 (見下面),
    "activeCamera_": string,
    "lights": 光源數組(見下面),
    "materials": 材質數組 (見下面),
    "geometries": {...} (見下面),
    "meshes": 網格數組 (見下面),
    "multiMaterials": 多材質數組(見下面),
    "shadowGenerators":  陰影生成器數組 (見下面),
    "skeletons": 骨架數組 (見下面),
    "particleSystems": 例子系統弄個數組 (見下面),
    "lensFlareSystems": 鏡頭光暈數組 (見下面),
    "actions": 動作數組 (見下面),
    "sounds": 音效數組 (見下面),
    "workerCollisions": boolean,
    "collisionsEnabled": boolean,
    "physicsEnabled": boolean,
    "physicsGravity": vector3 (默認是[0,-9.81,0]),
    "physicsEngine": string ("oimo""cannon", 引擎默認爲(oimo),
    "animations": 動畫數組 (見下面,可以省略),
    "autoAnimate": boolean,
    "autoAnimateFrom": int,
    "autoAnimateTo": int,
    "autoAnimateLoop": boolean (可以省略),
    "autoAnimateSpeed": number (可以省略)
}

相機

一個相機通過如下JSON格式定義:

{
    "name": string,
    "id": string,
    "type": string,
    "tags": string,
    "parentId": string,
    "lockedTargetId": string,
    "position": vector3,
    "target": vector3,
    "alpha": float, // 僅僅支持ArcRotateCamera 和 AnaglyphArcRotateCamera
    "beta": float, // 僅僅支持 ArcRotateCamera 和 AnaglyphArcRotateCamera
    "radius": float, // 僅僅支持 ArcRotateCamera, FollowCamera 和 AnaglyphArcRotateCamera
    "eye_space": float, // 僅僅支持 AnaglyphFreeCamera 和 AnaglyphArcRotateCamera
    "heightOffset": float, // 僅僅支持 FollowCamera
    "rotationOffset": float, // 僅僅支持 FollowCamera
    "cameraRigMode": int (可以忽略),
    "fov": float (弧度單位),
    "minZ": float,
    "maxZ": float,
    "speed": float,
    "inertia": float (在01間),
    "checkCollisions": boolean,
    "applyGravity": boolean,
    "ellipsoid": vector3,
    "animations": Animations數組 (見下面,可以忽略),
    "autoAnimate": boolean,
    "autoAnimateFrom": int,
    "autoAnimateTo": int,
    "autoAnimateLoop": boolean (可以忽略),
    "autoAnimateSpeed": number (可以忽略),
    "inputmgr" : 相機的輸入映射(可以忽略, 見下面)
}

相機的輸入映射

這是個對象,它字面上用輸入類型作爲鍵,同時用輸入設定作爲存儲值對象。每個輸入類型都有其自身的屬性.

光源

光源通過如下的JSON格式定義:

{
    "name": string,
    "id": string,
    "tags": string,
    "type": int (0表示點光,1表示方向光, 2表示聚光,3表示球面光),
    "position": vector3,
    "direction": vector3,
    "angle": float (用於點光源),
    "exponent": float (用於點光源),
    "groundColor": color3 (用於球面光光源),
    "intensity": float,
    "range": float,
    "diffuse": color3,
    "specular": color3,
    "excludedMeshesIds": array of string,
    "includedOnlyMeshesIds": array of string,
    "animations": array of Animations (見下面,可以忽略),
    "autoAnimate": boolean,
    "autoAnimateFrom": int,
    "autoAnimateTo": int,
    "autoAnimateLoop": boolean (可以忽略),
    "autoAnimateSpeed": number (可以忽略)
}

材質

一個材質通過如下JSON格式定義:

{
    "name": string,
    "id": string,
    "tags": string,
    "disableDepthWrite": boolean (可以忽略),
    "ambient": color3,
    "diffuse": color3,
    "specular": color3,
    "specularPower": float,
    "emissive": color3,
    "alpha": float,
    "backFaceCulling": boolean,
    "wireframe": boolean,
    "diffuseTexture": Texture (見下面),
    "ambientTexture": Texture (見下面),
    "opacityTexture": Texture (見下面,
    "reflectionTexture": Texture (見下面),
    "refractionTexture": Texture (見下面),
    "indexOfRefraction": float,
    "emissiveTexture": Texture (見下面),
    "specularTexture": Texture (見下面),
    "bumpTexture": Texture (見下面),
    "lightmapTexture": Texture (見下面),
    "useLightmapAsShadowmap": boolean,
    "checkReadyOnlyOnce": boolean
    "useReflectionFresnelFromSpecular": boolean (可以忽略),
    "useEmissiveAsIllumination": boolean (可以忽略),
    "diffuseFresnelParameters": 菲涅耳參數 (見下面),
    "opacityFresnelParameters": 菲涅耳參數 (見下面),
    "reflectionFresnelParameters": 菲涅耳參數 (見下面),
    "refractionFresnelParameters": 菲涅耳參數 (見下面),
    "emissiveFresnelParameters": 菲涅耳參數 (見下面)
}

菲涅耳參數

菲涅耳參數通過如下的JSON格式定義:

{
    "isEnabled": boolean,
    "leftColor": color3,
    "rightColor": color3,
    "bias": float,
    "power": float
}

紋理

紋理通過如下的JSON個格式定義:

{
    "name": string (文件名),
    "level": float (在01間),
    "hasAlpha": boolean,
    "getAlphaFromRGB": boolean,
    "coordinatesMode": int (0 = 顯式, 1 = 球, 2 = 平面, 3 = 立方, 4 = 投影, 5 = 天空盒),
    "uOffset": float,
    "vOffset": float,
    "uScale": float,
    "vScale": float,
    "uAng": float,
    "vAng": float,
    "wAng": float,
    "wrapU": boolean,
    "wrapV": boolean,
    "coordinatesIndex": int,
    "animations": array of Animations (見下面,可以忽略),
    "base64String": string (可以忽略)
}

多紋理

多紋理通過如下JSON格式定義:

{
    "name": string,
    "id": string,
    "tags": string,
    "materials": string數組 (都是子紋理的ID)
}

幾何體

幾何體的結構如下:

{
    "boxes": array of Boxes (見下面),
    "spheres": array of Spheres (見下面),
    "cylinders": array of Cylinders (見下面),
    "toruses": array of Toruses (見下面),
    "grounds": array of Grounds (見下面),
    "planes": array of Planes (見下面),
    "torusKnots": array of TorusKnots (見下面),
    "vertexData": array of VertexData (見下面)
}

盒子

盒子通過如下的JSON格式定義:

{
    "id": string,
    "size": float,
    "canBeRegenerated": bool,
    "tags": string
}

球體

球體通過如下的JSON格式定義:

{
    "id": string,
    "segments": float,
    "diameter": float,
    "canBeRegenerated": bool,
    "tags": string
}

圓柱體

圓柱體通過如下的JSON格式定義:

{
    "id": string,
    "height": float,
    "diameterTop": float,
    "diameterBottom": float,
    "tessellation": float,
    "subdivisions": integer,
    "canBeRegenerated": bool,
    "tags": string
}

環形體

環型體通過如下的JSON定義:

{
    "id": string,
    "diameter": float,
    "thickness": float,
    "tessellation": float,
    "canBeRegenerated": bool,
    "tags": string
}

地面

地面通過如下的JSON格式定義:

{
    "id": string,
    "width": float,
    "height": float,
    "subdivisions": float,
    "canBeRegenerated": bool,
    "tags": string
}

平面

平面通過如下的JSON格式定義:

{
    "id": string,
    "size": float,
    "canBeRegenerated": bool,
    "tags": string
}

環形節

環形節通過如下的JSON格式定義:

{
    "id": string,
    "radius": float,
    "tube": float,
    "radialSegments": float,
    "tubularSegments": float,
    "p": float,
    "q": float,
    "canBeRegenerated": bool,
    "tags": string
}

頂點數據

頂點數據通過如下的JSON格式定義:

{
    "id": string,
    "updatable": bool,
    "positions": array of floats (每頂點3個數值),
    "normals": array of floats (每頂點3個數值),
    "uvs": array of floats (每頂點2個數值),
    "uv2s": array of floats (每頂點2個數值) 第2個紋理座標 (可以忽略),
    "uv3s": array of floats (每頂點2個數值) 第3個紋理座標 (可以忽略),
    "uv4s": array of floats (每頂點2個數值) 第4個紋理座標 (可以忽略),
    "uv5s": array of floats (每頂點2個數值) 第5個紋理座標 (可以忽略),
    "uv6s": array of floats (每頂點2個數值) 第6個紋理座標 (可以忽略),
    "colors": array of floats (每頂點3個數值)每個頂點的顏色 (可以忽略),
    "matricesIndices": array of ints (每頂點4個數值) 骨骼數據在矩陣數組裏的索引 (可以忽略),
    "matricesWeights": array of floats (每頂點4個數值) 骨骼數據在矩陣數組裏的權重  (可以忽略),
    "indices": array of ints (每面點3個數值),
    "tags": string
}

實例

實例通過如下的JSON格式定義:

{
    "name": string,
    "tags": string,
    "position": vector3,
    "rotation": vector3 (可以忽略),
    "rotationQuaternion": vector4 (可以忽略),
    "scaling": vector3
}

網格

網格通過如下的JSON格式定義:

{
    "name": string,
    "id": string,
    "tags": string,
    "parentId": string,
    "materialId": string,
    "geometryId": string (可以忽略),
    "position": vector3,
    "rotation": vector3 (可以忽略),
    "rotationQuaternion": vector4 (可以忽略),
    "scaling": vector3,
    "pivotMatrix": matrix,
    "freezeWorldMatrix": boolean (可以忽略),
    "infiniteDistance": boolean,
    "showBoundingBox": boolean,
    "showSubMeshesBoundingBox": boolean,
    "isVisible": boolean,
    "isEnabled": boolean,
    "pickable": boolean,
    "applyFog": boolean,
    "alphaIndex": int,
    "checkCollisions": boolean,
    "billboardMode": int (0 = None, 1 = X, 2 = Y, 4 = Z, 7 = All),
    "receiveShadows": boolean,
    "physicsImpostor": int (0 = None, 1 = Box, 2 = Sphere),
    "physicsMass": float,
    "physicsFriction": float,
    "physicsRestitution": float,
    "positions": array of floats (每頂點3個數值),
    "normals": array of floats (每頂點3個數值),
    "uvs": array of floats (每頂點2個數值),
    "uvs2": array of floats (每頂點2個數值)  第2個紋理座標(可以忽略),
    "uv3s": array of floats (每頂點2個數值)  第3個紋理座標 (可以忽略),
    "uv4s": array of floats (每頂點2個數值)  第5個紋理座標 (可以忽略),
    "uv5s": array of floats (每頂點2個數值)  第6個紋理座標 (可以忽略),
    "uv6s": array of floats (每頂點2個數值)  第7個紋理座標 (可以忽略),
    "colors": array of floats (每頂點4個數值) 每個頂點的顏色 (可以忽略),
    "hasVertexAlpha": 指明顏色是否包含透明信息的值(可以忽略),
    "matricesIndices": array of ints (每頂點4個數值)  骨骼數據在矩陣數組裏的索引  (可以忽略),
    "matricesWeights": array of floats (每頂點4個數值)  骨骼數據在矩陣數組裏的權重 (可以忽略),
    "indices": array of ints (每面3個數值,
    "subMeshes": array of SubMeshes (見下面),
    "animations": array of Animations (見下面, 可以忽略),
    "autoAnimate": boolean,
    "autoAnimateFrom": int,
    "autoAnimateTo": int,
    "autoAnimateLoop": boolean,
    "autoAnimateSpeed": number (可以忽略)
    "instances": array of Instances (見下面, 可以忽略),
    "actions": array of actions (見下面)
}

請注意,父網格的描述必須在其子節點出現之前。

子網格

子網格通過如下的JSON格式定義:

{
    "materialIndex": int,
    "verticesStart": int,
    "verticesCount": int,
    "indexStart": int,
    "indexCount": int
}

動畫

動畫通過如下的JSON格式定義:

{
    "dataType": int (0 = 浮點, 1 = 3元量, 2 = 4元量, 3 = 矩陣),
    "framePerSecond": int,
    "loopBehavior": int (0 = 相對, 1 = 週期, 2 = 常量),
    "name": string,
    "property": string,
    "keys": array of AnimationKeys (見下面),
    "autoAnimate": boolean,
    "autoAnimateFrom": int,
    "autoAnimateTo": int,
    "autoAnimateLoop": boolean
}

動畫關鍵幀

動畫關鍵幀通過如下的JSON格式定義:

{
    "frame": int,
    "values": array of float (取決於播放的值)
}

陰影生成器

陰影生成器通過如下的JSON格式定義:

{
    "useBlurVarianceShadowMap": boolean,
    "useVarianceShadowMap": boolean,
    "usePoissonSampling": boolean,
    "mapSize": int (在642048之間, 必須是2的冪),
    "bias": float,
    "forceBackFacesOnly": float,
    "lightId": string,
    "renderList": array of string (網格的ID)
}

骨架

骨架通過如下的JSON格式定義:

{
    "name": string,
    "id": string,
    "bones": array of Bones (見下面)
    "needInitialSkinMatrix": boolean
}

骨骼

骨骼通過如下的JSON格式定義:

{
    "parentBoneIndex": int,
    "name": string,
    "matrix": matrix,
    "animations": array of Animations (必須是個矩陣類型)
}

粒子系統

粒子系統通過如下的JSON格式定義:

{
     "emitterId": string,
     "gravity": vector3,
     "direction1": vector3,
     "direction2": vector3,
     "minEmitBox": vector3,
     "maxEmitBox": vector3,
     "color1": color3,
     "color2": color3,
     "colorDead": color3,
     "deadAlpha": float,
     "emitRate": float,
     "updateSpeed": float,
     "targetStopFrame": int,
     "minEmitPower": int,
     "maxEmitPower": float,
     "minLifeTime": float,
     "maxLifeTime": float,
     "minSize": float,
     "maxSize": float,
     "minAngularSpeed": float,
     "maxAngularSpeed": float,
     "textureName": string,
     "blendMode": int,
     "capacity": int,
     "textureMask": color4,
     "linkToEmitter": bool,
    "animations": Animations數組 (見下面,可以省略),
    "autoAnimate": boolean,
    "autoAnimateFrom": int,
    "autoAnimateTo": int,
    "autoAnimateLoop": boolean (可以省略),
    "autoAnimateSpeed": number (可以忽略)
}

鏡頭光暈系統

鏡頭光暈系統通過如下的JSON格式定義:

{
     "emitterId": string,
     "borderLimit": int,
     "flares": array of LensFlares (見下面)
}

鏡頭光暈

鏡頭光暈通過如下的JSON格式定義:

{
     "position": float,
     "size": float,
     "color": color3,
     "textureName": string
}

音效

音效通過如下的JSON格式定義:

{
     "name": string, (要加載的文件名)
     "volume": float, (如果忽略則爲1)
     "autoplay": bool, (可忽略)
     "loop": bool, (可忽略)
     "soundTrackId": int, (可忽略)
     "spatialSound": bool, (啓用3維音效,可忽略)
     "position": vector3, (如果忽略則爲0,0,0)
     "refDistance": float, (可忽略, 默認爲1)
     "rolloffFactor": float, (可忽略, 默認爲1)
     "maxDistance": float, (可忽略, 默認爲100)
     "distanceModel": string, (可忽略, 默認爲線性的,其它值: 倒數或指數)
     "panningModel": string, (可忽略, 默認爲HRTF, 其它值: 等冪)
     "isDirectional": bool, (啓用方向椎體)
     "coneInnerAngle": float, (可忽略,用來設置有向音效)
     "coneOuterAngle": float, (可忽略,用來設置有向音效)
     "coneOuterGain": float, (可忽略,用來設置有向音效)
     "connectedMeshId": string, (網格附着對象的ID)
     "localDirectionToMesh": vector3 (可忽略,默認1,0,0)
}

動作

動作通過如下的JSON格式定義. 動作可以包含多個子的動作.

{
    "type": number, (動作類型. 0 = 觸發式, 1 = 動作, 2 = 流控制)
    "name": string, (觸發式或流程的動作名)
    "detached": boolean, (節點是否掛載上. 如果detached === true意味着不會被計算)
    "properties": array of properties, (見下面)
    "children": array of Actions,
    "combine": array of Actions (用於組合動畫. 例如 name = "CombineAction". 可以爲null)
}

屬性通過如下JSON格式定義. 屬性值總是字符串

{
    "name": string, (屬性名)
    "value": string, (屬性值. 例如: name = "target" 和 value = "Plane001")
    "targetType": string (BabylonJS動作創建器內部使用的, 指明在哪找到"propertyPath"屬性的)
}

例子

這兒是個簡單的.babylon文件的例子:

{
    "autoClear": true,
    "clearColor": [0, 0, 0],
    "ambientColor": [0, 0, 0],
    "gravity": [0, -9.81, 0],
    "cameras": [{
        "name": "Camera",
        "id": "Camera",
        "position": [7.4811, 5.3437, -6.5076],
        "target": [-0.3174, 0.8953, 0.3125],
        "fov": 0.8576,
        "minZ": 0.1,
        "maxZ": 100,
        "speed": 1,
        "inertia": 0.9,
        "checkCollisions": false,
        "applyGravity": false,
        "ellipsoid": [0.2, 0.9, 0.2]
    }],
    "activeCamera": "Camera",
    "lights": [{
        "name": "Sun",
        "id": "Sun",
        "type": 1,
        "position": [0.926, 7.3608, 14.1829],
        "direction": [-0.347, -0.4916, -0.7987],
        "intensity": 1,
        "diffuse": [1, 1, 1],
        "specular": [1, 1, 1]
    }],
    "materials": [{
        "name": "Material",
        "id": "Material",
        "ambient": [0.8, 0.8, 0.8],
        "diffuse": [0.64, 0.64, 0.64],
        "specular": [0.5, 0.5, 0.5],
        "specularPower": 50,
        "emissive": [0, 0, 0],
        "alpha": 1,
        "backFaceCulling": true,
        "diffuseTexture": {
            "name": "Metal1.png",
            "level": 1,
            "hasAlpha": 1,
            "coordinatesMode": 0,
            "uOffset": 0,
            "vOffset": 0,
            "uScale": 1,
            "vScale": 1,
            "uAng": 0,
            "vAng": 0,
            "wAng": 0,
            "wrapU": true,
            "wrapV": true,
            "coordinatesIndex": 0
        }
    },
    {
        "name": "Material.001",
        "id": "Material.001",
        "ambient": [0.8, 0.8, 0.8],
        "diffuse": [0.64, 0.64, 0.64],
        "specular": [0.5, 0.5, 0.5],
        "specularPower": 50,
        "emissive": [0, 0, 0],
        "alpha": 1,
        "backFaceCulling": true,
        "diffuseTexture": {
            "name": "concrete5.png",
            "level": 1,
            "hasAlpha": 1,
            "coordinatesMode": 0,
            "uOffset": 0,
            "vOffset": 0,
            "uScale": 5,
            "vScale": 5,
            "uAng": 0,
            "vAng": 0,
            "wAng": 0,
            "wrapU": true,
            "wrapV": true,
            "coordinatesIndex": 0
        }
    }],
    "geometries": {
        "boxes": [{
            "id": "BoxPrimitive",
            "size": 2,
            "canBeRegenerated": true,
            "tags": "Box Primitive Cube CanBeRegenerated"
        }],
        "vertexData": [{
            "id": "CubeGeometry",
            "updatable": false,
            "positions": [ 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1],
            "normals": [0.5773, -0.5773, 0.5773, 0.5773, -0.5773, -0.5773, -0.5773, -0.5773, 0.5773, 0.5773, 0.5773, 0.5773, -0.5773, 0.5773, 0.5773, 0.5773, 0.5773, -0.5773, 0.5773, 0.5773, 0.5773, 0.5773, -0.5773, -0.5773, 0.5773, -0.5773, -0.5773, 0.5773, 0.5773, -0.5773, -0.5773, -0.5773, -0.5773, -0.5773, -0.5773, -0.5773, -0.5773, 0.5773, -0.5773, -0.5773, -0.5773, 0.5773, 0.5773, 0.5773, 0.5773, 0.5773, -0.5773, 0.5773, -0.5773, 0.5773, 0.5773, -0.5773, -0.5773, -0.5773, -0.5773, 0.5773, -0.5773, 0.5773, 0.5773, 0.5773, 0.5773, 0.5773, -0.5773, 0.5773, -0.5773, -0.5773, 0.5773, 0.5773, -0.5773, -0.5773, 0.5773, -0.5773, -0.5773, 0.5773, 0.5773, -0.5773, -0.5773, 0.5773, 0.5773, -0.5773, 0.5773, -0.5773, -0.5773, 0.5773, -0.5773, 0.5773, 0.5773],
            "uvs": [0.5, 0.5, 0.5, 0, 0, 0.5, 0.5, 1, 0, 1, 0.5, 0.5, 0.5, 1, 0, 0.5, 0.5, 0.5, 0.5, 1, 0, 0.5, 0.5, 0.5, 0.5, 1, 1, 0.5, 0.5, 0.5, 0.5, 0, 0, 0.5, 0, 0, 0, 0.5, 0.5, 1, 0, 1, 0, 0.5, 0.5, 1, 0, 1, 1, 1, 1, 0.5, 0.5, 0, 0, 0, 0, 0.5],
            "indices": [0, 1, 2, 3, 4, 5, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1, 17, 2, 4, 18, 5, 19, 20, 21, 22, 23, 10, 12, 24, 25, 26, 27, 28]
        }]
    },
    "meshes": [{
        "name": "Plane",
        "id": "Plane",
        "materialId": "Material.001",
        "position": [0.0172, -2.9787, -0.5184],
        "rotation": [0, 0, 0],
        "scaling": [87.1479, 0.8635, 87.1479],
        "isVisible": true,
        "isEnabled": true,
        "checkCollisions": false,
        "billboardMode": 0,
        "receiveShadows": true,
        "positions": [-1, 0, -1, 1, 0, -1, -1, 0, 1, 1, 0, 1],
        "normals": [0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0],
        "uvs": [0.0001, 0.0001, 0.9999, 0.0001, 0.0001, 0.9999, 0.9999, 0.9999],
        "indices": [0, 1, 2, 1, 3, 2],
        "subMeshes": [{
            "materialIndex": 0,
            "verticesStart": 0,
            "verticesCount": 4,
            "indexStart": 0,
            "indexCount": 6
        }]
    },
    {
        "name": "Cube",
        "id": "Cube",
        "materialId": "Material",
        "geometryId": "CubeGeometry",
        "position": [0, 0, 0],
        "rotation": [0, 0, 0],
        "scaling": [1, 1, 1],
        "isVisible": true,
        "isEnabled": true,
        "checkCollisions": false,
        "billboardMode": 0,
        "receiveShadows": false,
        "subMeshes": [{
            "materialIndex": 0,
            "verticesStart": 0,
            "verticesCount": 29,
            "indexStart": 0,
            "indexCount": 36
        }],
        "animations": [{
            "dataType": 1,
            "framePerSecond": 30,
            "loopBehavior": 1,
            "name": "position animation",
            "property": "position",
            "keys": [{
                "frame": 0,
                "values": [0,0,0.0291]
            },
            {
                "frame": 1,
                "values": [0,0,0.0291]
            },
            {
                "frame": 30,
                "values": [0,0,10]
            },
            {
                "frame": 60,
                "values": [0,0,9.975]
            },
            {
                "frame": 90,
                "values": [0,0,0]
            },
            {
                "frame": 250,
                "values": [0,0,0]
            }]
        },
        {
            "dataType": 1,
            "framePerSecond": 30,
            "loopBehavior": 1,
            "name": "rotation animation",
            "property": "rotation",
            "keys": [{
                "frame": 0,
                "values": [-0.016, 0, 0]
            },
            {
                "frame": 30,
                "values": [-0.016, 0, 0]
            },
            {
                "frame": 60,
                "values": [-6.2832, 0, 0]
            },
            {
                "frame": 250,
                "values": [-6.2832, 0, 0]
            }]
        }],
        "autoAnimate": true,
        "autoAnimateFrom": 0,
        "autoAnimateTo": 250,
        "autoAnimateLoop": true
    },
    {
        "name": "Cube2",
        "id": "Cube2",
        "materialId": "Material",
        "geometryId": "CubeGeometry",
        "position": [10, 0, 0],
        "rotation": [0, 0, 0],
        "scaling": [1, 1, 1],
        "isVisible": true,
        "isEnabled": true,
        "checkCollisions": false,
        "billboardMode": 0,
        "receiveShadows": false,
        "subMeshes": [{
            "materialIndex": 0,
            "verticesStart": 0,
            "verticesCount": 29,
            "indexStart": 0,
            "indexCount": 36
        }]
    },
    {
        "name": "Cube3",
        "id": "Cube3",
        "materialId": "Material",
        "geometryId": "BoxPrimitive",
        "position": [-10, 0, 0],
        "rotation": [0, 0, 0],
        "scaling": [1, 1, 1],
        "isVisible": true,
        "isEnabled": true,
        "checkCollisions": false,
        "billboardMode": 0,
        "receiveShadows": false,
        "subMeshes": [{
            "materialIndex": 0,
            "verticesStart": 0,
            "verticesCount": 29,
            "indexStart": 0,
            "indexCount": 36
        }]
    }],
    "multiMaterials": [],
    "shadowGenerators": [{
        "useVarianceShadowMap": true,
        "mapSize": 1024,
        "lightId": "Sun",
        "renderList": ["Cube", "Cube2", "Cube3"]
    }],
    "skeletons": [],
    "sounds": [{
        "name": "violons11.wav",
        "volume": 1,
        "autoplay": true,
        "loop": true,
        "soundTrackId": 1
        "spatialSound": true,
        "position": [0, 0, 0]
        "refDistance": 1.0,
        "rolloffFactor": 1.0,
        "maxDistance": 100,
        "distanceModel": "linear",
        "panningModel": "equalpower",
        "isDirectional": false,
        "coneInnerAngle": 90,
        "coneOuterAngle": 180,
        "coneOuterGain": 0,
        "connectedMeshId": 0,
        "localDirectionToMesh": [1, 0, 0]
   }]
}

原文地址:http://doc.babylonjs.com/generals/File_Format_Map_(.babylon)#grounds
github上譯文:https://github.com/h53d/babylonjs-doc-cn/blob/master/target/generals/General/File_Format_Map_(.babylon).md

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章