6ee7916a5668e66a94904ff234dd6fcb7ca4055e4433c5fd3c9e0dfc78c3a3ac.json 14 KB

1
  1. {"ast":null,"code":"import { Mesh } from \"../mesh.js\";\nimport { VertexData } from \"../mesh.vertexData.js\";\nimport { useOpenGLOrientationForUV } from \"../../Compat/compatibilityOptions.js\";\n/**\n * Creates the VertexData for a Plane\n * @param options an object used to set the following optional parameters for the plane, required but can be empty\n * * size sets the width and height of the plane to the value of size, optional default 1\n * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size\n * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size\n * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE\n * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)\n * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)\n * @returns the VertexData of the box\n */\nexport function CreatePlaneVertexData(options) {\n const indices = [];\n const positions = [];\n const normals = [];\n const uvs = [];\n const width = options.width || options.size || 1;\n const height = options.height || options.size || 1;\n const sideOrientation = options.sideOrientation === 0 ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;\n // Vertices\n const halfWidth = width / 2.0;\n const halfHeight = height / 2.0;\n positions.push(-halfWidth, -halfHeight, 0);\n normals.push(0, 0, -1.0);\n uvs.push(0.0, useOpenGLOrientationForUV ? 1.0 : 0.0);\n positions.push(halfWidth, -halfHeight, 0);\n normals.push(0, 0, -1.0);\n uvs.push(1.0, useOpenGLOrientationForUV ? 1.0 : 0.0);\n positions.push(halfWidth, halfHeight, 0);\n normals.push(0, 0, -1.0);\n uvs.push(1.0, useOpenGLOrientationForUV ? 0.0 : 1.0);\n positions.push(-halfWidth, halfHeight, 0);\n normals.push(0, 0, -1.0);\n uvs.push(0.0, useOpenGLOrientationForUV ? 0.0 : 1.0);\n // Indices\n indices.push(0);\n indices.push(1);\n indices.push(2);\n indices.push(0);\n indices.push(2);\n indices.push(3);\n // Sides\n VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);\n // Result\n const vertexData = new VertexData();\n vertexData.indices = indices;\n vertexData.positions = positions;\n vertexData.normals = normals;\n vertexData.uvs = uvs;\n return vertexData;\n}\n/**\n * Creates a plane mesh\n * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)\n * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)\n * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane\n * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE\n * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set#side-orientation\n * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created\n * @param name defines the name of the mesh\n * @param options defines the options used to create the mesh\n * @param scene defines the hosting scene\n * @returns the plane mesh\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set#plane\n */\nexport function CreatePlane(name, options = {}, scene = null) {\n const plane = new Mesh(name, scene);\n options.sideOrientation = Mesh._GetDefaultSideOrientation(options.sideOrientation);\n plane._originalBuilderSideOrientation = options.sideOrientation;\n const vertexData = CreatePlaneVertexData(options);\n vertexData.applyToMesh(plane, options.updatable);\n if (options.sourcePlane) {\n plane.translate(options.sourcePlane.normal, -options.sourcePlane.d);\n plane.setDirection(options.sourcePlane.normal.scale(-1));\n }\n return plane;\n}\n/**\n * Class containing static functions to help procedurally build meshes\n * @deprecated use the function directly from the module\n */\nexport const PlaneBuilder = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n CreatePlane\n};\nVertexData.CreatePlane = CreatePlaneVertexData;\nMesh.CreatePlane = (name, size, scene, updatable, sideOrientation) => {\n const options = {\n size,\n width: size,\n height: size,\n sideOrientation,\n updatable\n };\n return CreatePlane(name, options, scene);\n};","map":{"version":3,"names":["Mesh","VertexData","useOpenGLOrientationForUV","CreatePlaneVertexData","options","indices","positions","normals","uvs","width","size","height","sideOrientation","DEFAULTSIDE","halfWidth","halfHeight","push","_ComputeSides","frontUVs","backUVs","vertexData","CreatePlane","name","scene","plane","_GetDefaultSideOrientation","_originalBuilderSideOrientation","applyToMesh","updatable","sourcePlane","translate","normal","d","setDirection","scale","PlaneBuilder"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Meshes/Builders/planeBuilder.js"],"sourcesContent":["import { Mesh } from \"../mesh.js\";\nimport { VertexData } from \"../mesh.vertexData.js\";\nimport { useOpenGLOrientationForUV } from \"../../Compat/compatibilityOptions.js\";\n/**\n * Creates the VertexData for a Plane\n * @param options an object used to set the following optional parameters for the plane, required but can be empty\n * * size sets the width and height of the plane to the value of size, optional default 1\n * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size\n * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size\n * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE\n * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)\n * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)\n * @returns the VertexData of the box\n */\nexport function CreatePlaneVertexData(options) {\n const indices = [];\n const positions = [];\n const normals = [];\n const uvs = [];\n const width = options.width || options.size || 1;\n const height = options.height || options.size || 1;\n const sideOrientation = options.sideOrientation === 0 ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;\n // Vertices\n const halfWidth = width / 2.0;\n const halfHeight = height / 2.0;\n positions.push(-halfWidth, -halfHeight, 0);\n normals.push(0, 0, -1.0);\n uvs.push(0.0, useOpenGLOrientationForUV ? 1.0 : 0.0);\n positions.push(halfWidth, -halfHeight, 0);\n normals.push(0, 0, -1.0);\n uvs.push(1.0, useOpenGLOrientationForUV ? 1.0 : 0.0);\n positions.push(halfWidth, halfHeight, 0);\n normals.push(0, 0, -1.0);\n uvs.push(1.0, useOpenGLOrientationForUV ? 0.0 : 1.0);\n positions.push(-halfWidth, halfHeight, 0);\n normals.push(0, 0, -1.0);\n uvs.push(0.0, useOpenGLOrientationForUV ? 0.0 : 1.0);\n // Indices\n indices.push(0);\n indices.push(1);\n indices.push(2);\n indices.push(0);\n indices.push(2);\n indices.push(3);\n // Sides\n VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);\n // Result\n const vertexData = new VertexData();\n vertexData.indices = indices;\n vertexData.positions = positions;\n vertexData.normals = normals;\n vertexData.uvs = uvs;\n return vertexData;\n}\n/**\n * Creates a plane mesh\n * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)\n * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)\n * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane\n * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE\n * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set#side-orientation\n * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created\n * @param name defines the name of the mesh\n * @param options defines the options used to create the mesh\n * @param scene defines the hosting scene\n * @returns the plane mesh\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set#plane\n */\nexport function CreatePlane(name, options = {}, scene = null) {\n const plane = new Mesh(name, scene);\n options.sideOrientation = Mesh._GetDefaultSideOrientation(options.sideOrientation);\n plane._originalBuilderSideOrientation = options.sideOrientation;\n const vertexData = CreatePlaneVertexData(options);\n vertexData.applyToMesh(plane, options.updatable);\n if (options.sourcePlane) {\n plane.translate(options.sourcePlane.normal, -options.sourcePlane.d);\n plane.setDirection(options.sourcePlane.normal.scale(-1));\n }\n return plane;\n}\n/**\n * Class containing static functions to help procedurally build meshes\n * @deprecated use the function directly from the module\n */\nexport const PlaneBuilder = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n CreatePlane,\n};\nVertexData.CreatePlane = CreatePlaneVertexData;\nMesh.CreatePlane = (name, size, scene, updatable, sideOrientation) => {\n const options = {\n size,\n width: size,\n height: size,\n sideOrientation,\n updatable,\n };\n return CreatePlane(name, options, scene);\n};\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,YAAY;AACjC,SAASC,UAAU,QAAQ,uBAAuB;AAClD,SAASC,yBAAyB,QAAQ,sCAAsC;AAChF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CAACC,OAAO,EAAE;EAC3C,MAAMC,OAAO,GAAG,EAAE;EAClB,MAAMC,SAAS,GAAG,EAAE;EACpB,MAAMC,OAAO,GAAG,EAAE;EAClB,MAAMC,GAAG,GAAG,EAAE;EACd,MAAMC,KAAK,GAAGL,OAAO,CAACK,KAAK,IAAIL,OAAO,CAACM,IAAI,IAAI,CAAC;EAChD,MAAMC,MAAM,GAAGP,OAAO,CAACO,MAAM,IAAIP,OAAO,CAACM,IAAI,IAAI,CAAC;EAClD,MAAME,eAAe,GAAGR,OAAO,CAACQ,eAAe,KAAK,CAAC,GAAG,CAAC,GAAGR,OAAO,CAACQ,eAAe,IAAIX,UAAU,CAACY,WAAW;EAC7G;EACA,MAAMC,SAAS,GAAGL,KAAK,GAAG,GAAG;EAC7B,MAAMM,UAAU,GAAGJ,MAAM,GAAG,GAAG;EAC/BL,SAAS,CAACU,IAAI,CAAC,CAACF,SAAS,EAAE,CAACC,UAAU,EAAE,CAAC,CAAC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