@luma.gl/engine 9.0.0-alpha.14 → 9.0.0-alpha.16
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.
- package/dist/animation/key-frames.d.ts +1 -1
- package/dist/animation/key-frames.d.ts.map +1 -1
- package/dist/animation/key-frames.js +51 -72
- package/dist/animation/timeline.d.ts +4 -4
- package/dist/animation/timeline.d.ts.map +1 -1
- package/dist/animation/timeline.js +94 -131
- package/dist/animation-loop/animation-loop.d.ts +2 -3
- package/dist/animation-loop/animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/animation-loop.js +414 -473
- package/dist/animation-loop/animation-props.d.ts +1 -2
- package/dist/animation-loop/animation-props.d.ts.map +1 -1
- package/dist/animation-loop/animation-props.js +0 -1
- package/dist/animation-loop/make-animation-loop.d.ts +1 -1
- package/dist/animation-loop/make-animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/make-animation-loop.js +26 -31
- package/dist/animation-loop/render-loop.js +17 -7
- package/dist/bundle.js +2 -2
- package/dist/dist.min.js +31 -0
- package/dist/es5/animation/key-frames.js +84 -0
- package/dist/es5/animation/key-frames.js.map +1 -0
- package/dist/es5/animation/timeline.js +183 -0
- package/dist/es5/animation/timeline.js.map +1 -0
- package/dist/es5/animation-loop/animation-loop.js +534 -0
- package/dist/es5/animation-loop/animation-loop.js.map +1 -0
- package/dist/es5/animation-loop/animation-props.js +2 -0
- package/dist/es5/animation-loop/animation-props.js.map +1 -0
- package/dist/es5/animation-loop/make-animation-loop.js +53 -0
- package/dist/es5/animation-loop/make-animation-loop.js.map +1 -0
- package/dist/es5/animation-loop/render-loop.js +39 -0
- package/dist/es5/animation-loop/render-loop.js.map +1 -0
- package/dist/es5/bundle.js +6 -0
- package/dist/es5/bundle.js.map +1 -0
- package/dist/es5/geometries/cone-geometry.js +43 -0
- package/dist/es5/geometries/cone-geometry.js.map +1 -0
- package/dist/es5/geometries/cube-geometry.js +84 -0
- package/dist/es5/geometries/cube-geometry.js.map +1 -0
- package/dist/es5/geometries/cylinder-geometry.js +39 -0
- package/dist/es5/geometries/cylinder-geometry.js.map +1 -0
- package/dist/es5/geometries/ico-sphere-geometry.js +185 -0
- package/dist/es5/geometries/ico-sphere-geometry.js.map +1 -0
- package/dist/es5/geometries/plane-geometry.js +137 -0
- package/dist/es5/geometries/plane-geometry.js.map +1 -0
- package/dist/es5/geometries/sphere-geometry.js +120 -0
- package/dist/es5/geometries/sphere-geometry.js.map +1 -0
- package/dist/es5/geometries/truncated-cone-geometry.js +160 -0
- package/dist/es5/geometries/truncated-cone-geometry.js.map +1 -0
- package/dist/es5/geometry/geometry-table.js +2 -0
- package/dist/es5/geometry/geometry-table.js.map +1 -0
- package/dist/es5/geometry/geometry-utils.js +39 -0
- package/dist/es5/geometry/geometry-utils.js.map +1 -0
- package/dist/es5/geometry/geometry.js +150 -0
- package/dist/es5/geometry/geometry.js.map +1 -0
- package/dist/es5/geometry/primitive-utils.js +2 -0
- package/dist/es5/geometry/primitive-utils.js.map +1 -0
- package/dist/es5/index.js +112 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/lib/clip-space.js +2 -0
- package/dist/es5/lib/clip-space.js.map +1 -0
- package/dist/es5/lib/model-utils.js +52 -0
- package/dist/es5/lib/model-utils.js.map +1 -0
- package/dist/es5/lib/model.js +173 -0
- package/dist/es5/lib/model.js.map +1 -0
- package/dist/es5/lib/pipeline-factory.js +244 -0
- package/dist/es5/lib/pipeline-factory.js.map +1 -0
- package/dist/esm/animation/key-frames.js +57 -0
- package/dist/esm/animation/key-frames.js.map +1 -0
- package/dist/esm/animation/timeline.js +113 -0
- package/dist/esm/animation/timeline.js.map +1 -0
- package/dist/esm/animation-loop/animation-loop.js +367 -0
- package/dist/esm/animation-loop/animation-loop.js.map +1 -0
- package/dist/esm/animation-loop/animation-props.js +2 -0
- package/dist/esm/animation-loop/animation-props.js.map +1 -0
- package/dist/esm/animation-loop/make-animation-loop.js +28 -0
- package/dist/esm/animation-loop/make-animation-loop.js.map +1 -0
- package/dist/esm/animation-loop/render-loop.js +7 -0
- package/dist/esm/animation-loop/render-loop.js.map +1 -0
- package/dist/esm/bundle.js +4 -0
- package/dist/esm/bundle.js.map +1 -0
- package/dist/esm/geometries/cone-geometry.js +21 -0
- package/dist/esm/geometries/cone-geometry.js.map +1 -0
- package/dist/esm/geometries/cube-geometry.js +67 -0
- package/dist/esm/geometries/cube-geometry.js.map +1 -0
- package/dist/esm/geometries/cylinder-geometry.js +18 -0
- package/dist/esm/geometries/cylinder-geometry.js.map +1 -0
- package/dist/esm/geometries/ico-sphere-geometry.js +170 -0
- package/dist/esm/geometries/ico-sphere-geometry.js.map +1 -0
- package/dist/esm/geometries/plane-geometry.js +119 -0
- package/dist/esm/geometries/plane-geometry.js.map +1 -0
- package/dist/esm/geometries/sphere-geometry.js +102 -0
- package/dist/esm/geometries/sphere-geometry.js.map +1 -0
- package/dist/esm/geometries/truncated-cone-geometry.js +136 -0
- package/dist/esm/geometries/truncated-cone-geometry.js.map +1 -0
- package/dist/esm/geometry/geometry-table.js +2 -0
- package/dist/esm/geometry/geometry-table.js.map +1 -0
- package/dist/esm/geometry/geometry-utils.js +37 -0
- package/dist/esm/geometry/geometry-utils.js.map +1 -0
- package/dist/esm/geometry/geometry.js +119 -0
- package/dist/esm/geometry/geometry.js.map +1 -0
- package/dist/esm/geometry/primitive-utils.js +2 -0
- package/dist/esm/geometry/primitive-utils.js.map +1 -0
- package/dist/esm/index.js +16 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/clip-space.js +2 -0
- package/dist/esm/lib/clip-space.js.map +1 -0
- package/dist/esm/lib/model-utils.js +40 -0
- package/dist/esm/lib/model-utils.js.map +1 -0
- package/dist/esm/lib/model.js +146 -0
- package/dist/esm/lib/model.js.map +1 -0
- package/dist/esm/lib/pipeline-factory.js +180 -0
- package/dist/esm/lib/pipeline-factory.js.map +1 -0
- package/dist/geometries/cone-geometry.d.ts +1 -1
- package/dist/geometries/cone-geometry.d.ts.map +1 -1
- package/dist/geometries/cone-geometry.js +12 -17
- package/dist/geometries/cube-geometry.d.ts +1 -1
- package/dist/geometries/cube-geometry.d.ts.map +1 -1
- package/dist/geometries/cube-geometry.js +187 -56
- package/dist/geometries/cylinder-geometry.d.ts +1 -1
- package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
- package/dist/geometries/cylinder-geometry.js +10 -14
- package/dist/geometries/ico-sphere-geometry.d.ts +1 -1
- package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
- package/dist/geometries/ico-sphere-geometry.js +141 -170
- package/dist/geometries/plane-geometry.d.ts +1 -1
- package/dist/geometries/plane-geometry.d.ts.map +1 -1
- package/dist/geometries/plane-geometry.js +93 -121
- package/dist/geometries/sphere-geometry.d.ts +1 -1
- package/dist/geometries/sphere-geometry.d.ts.map +1 -1
- package/dist/geometries/sphere-geometry.js +76 -100
- package/dist/geometries/truncated-cone-geometry.d.ts +1 -1
- package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
- package/dist/geometries/truncated-cone-geometry.js +104 -131
- package/dist/geometry/geometry-table.d.ts +1 -1
- package/dist/geometry/geometry-table.d.ts.map +1 -1
- package/dist/geometry/geometry-table.js +0 -1
- package/dist/geometry/geometry-utils.js +22 -41
- package/dist/geometry/geometry.d.ts +4 -4
- package/dist/geometry/geometry.d.ts.map +1 -1
- package/dist/geometry/geometry.js +96 -142
- package/dist/geometry/primitive-utils.js +30 -1
- package/dist/index.js +20 -16
- package/dist/lib/clip-space.js +50 -1
- package/dist/lib/model-utils.js +97 -29
- package/dist/lib/model.d.ts +1 -1
- package/dist/lib/model.d.ts.map +1 -1
- package/dist/lib/model.js +122 -166
- package/dist/lib/pipeline-factory.d.ts +3 -3
- package/dist/lib/pipeline-factory.d.ts.map +1 -1
- package/dist/lib/pipeline-factory.js +136 -204
- package/package.json +12 -11
- package/dist/animation/key-frames.js.map +0 -1
- package/dist/animation/timeline.js.map +0 -1
- package/dist/animation-loop/animation-loop.js.map +0 -1
- package/dist/animation-loop/animation-props.js.map +0 -1
- package/dist/animation-loop/make-animation-loop.js.map +0 -1
- package/dist/animation-loop/render-loop.js.map +0 -1
- package/dist/bundle.js.map +0 -1
- package/dist/geometries/cone-geometry.js.map +0 -1
- package/dist/geometries/cube-geometry.js.map +0 -1
- package/dist/geometries/cylinder-geometry.js.map +0 -1
- package/dist/geometries/ico-sphere-geometry.js.map +0 -1
- package/dist/geometries/plane-geometry.js.map +0 -1
- package/dist/geometries/sphere-geometry.js.map +0 -1
- package/dist/geometries/truncated-cone-geometry.js.map +0 -1
- package/dist/geometry/geometry-table.js.map +0 -1
- package/dist/geometry/geometry-utils.js.map +0 -1
- package/dist/geometry/geometry.js.map +0 -1
- package/dist/geometry/primitive-utils.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/clip-space.js.map +0 -1
- package/dist/lib/model-utils.js.map +0 -1
- package/dist/lib/model.js.map +0 -1
- package/dist/lib/pipeline-factory.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/geometries/plane-geometry.ts"],"names":["uid","Geometry","unpackIndexedGeometry","PlaneGeometry","constructor","props","id","indices","attributes","tesselatePlane","type","offset","flipCull","unpack","coords","split","c1len","c2len","subdivisions1","subdivisions2","numVertices","positions","Float32Array","normals","texCoords","i2","i3","z","x","u","v","Error","numVertsAcross","Uint16Array","index","geometry","size","value","POSITION","NORMAL","TEXCOORD_0"],"mappings":"AAAA,SAAQA,GAAR,QAAkB,cAAlB;AACA,OAAOC,QAAP,MAAqB,sBAArB;AACA,SAAQC,qBAAR,QAAoC,4BAApC;AAWA,OAAO,MAAMC,aAAN,SAA4BF,QAA5B,CAAqC;AAC1CG,EAAAA,WAAW,CAACC,KAAyB,GAAG,EAA7B,EAAiC;AAC1C,UAAM;AAACC,MAAAA,EAAE,GAAGN,GAAG,CAAC,gBAAD;AAAT,QAA+BK,KAArC;AAEA,UAAM;AAACE,MAAAA,OAAD;AAA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AAU,EAAE;AAACJ,QAAAA,IAAI,EAAE,CAAP;AAAUC,QAAAA,KAAK,EAAEb;AAAjB;AAHF;AAFG,GAAjB;AAUA,SAAOX,MAAM,GAAGX,qBAAqB,CAACiC,QAAD,CAAxB,GAAqCA,QAAlD;AACD","sourcesContent":["import {uid} from '@luma.gl/api';\nimport Geometry from '../geometry/geometry';\nimport {unpackIndexedGeometry} from '../geometry/geometry-utils';\n\nexport type PlaneGeometryProps = {\n id?: string;\n radius?: number;\n attributes?: any\n};\n\n// Primitives inspired by TDL http://code.google.com/p/webglsamples/,\n// copyright 2011 Google Inc. new BSD License\n// (http://www.opensource.org/licenses/bsd-license.php).\nexport class PlaneGeometry extends Geometry {\n constructor(props: PlaneGeometryProps = {}) {\n const {id = uid('plane-geometry')} = props;\n\n const {indices, attributes} = tesselatePlane(props);\n super({\n ...props,\n id,\n indices,\n attributes: {...attributes, ...props.attributes}\n });\n }\n}\n\n/* eslint-disable complexity, max-statements */\nfunction tesselatePlane(props: any) {\n const {type = 'x,y', offset = 0, flipCull = false, unpack = false} = props;\n\n const coords = type.split(',');\n // width, height\n let c1len = props[`${coords[0]}len`] || 1;\n const c2len = props[`${coords[1]}len`] || 1;\n // subdivisionsWidth, subdivisionsDepth\n const subdivisions1 = props[`n${coords[0]}`] || 1;\n const subdivisions2 = props[`n${coords[1]}`] || 1;\n const numVertices = (subdivisions1 + 1) * (subdivisions2 + 1);\n\n const positions = new Float32Array(numVertices * 3);\n const normals = new Float32Array(numVertices * 3);\n const texCoords = new Float32Array(numVertices * 2);\n\n if (flipCull) {\n c1len = -c1len;\n }\n\n let i2 = 0;\n let i3 = 0;\n for (let z = 0; z <= subdivisions2; z++) {\n for (let x = 0; x <= subdivisions1; x++) {\n const u = x / subdivisions1;\n const v = z / subdivisions2;\n texCoords[i2 + 0] = flipCull ? 1 - u : u;\n texCoords[i2 + 1] = v;\n\n switch (type) {\n case 'x,y':\n positions[i3 + 0] = c1len * u - c1len * 0.5;\n positions[i3 + 1] = c2len * v - c2len * 0.5;\n positions[i3 + 2] = offset;\n\n normals[i3 + 0] = 0;\n normals[i3 + 1] = 0;\n normals[i3 + 2] = flipCull ? 1 : -1;\n break;\n\n case 'x,z':\n positions[i3 + 0] = c1len * u - c1len * 0.5;\n positions[i3 + 1] = offset;\n positions[i3 + 2] = c2len * v - c2len * 0.5;\n\n normals[i3 + 0] = 0;\n normals[i3 + 1] = flipCull ? 1 : -1;\n normals[i3 + 2] = 0;\n break;\n\n case 'y,z':\n positions[i3 + 0] = offset;\n positions[i3 + 1] = c1len * u - c1len * 0.5;\n positions[i3 + 2] = c2len * v - c2len * 0.5;\n\n normals[i3 + 0] = flipCull ? 1 : -1;\n normals[i3 + 1] = 0;\n normals[i3 + 2] = 0;\n break;\n\n default:\n throw new Error('PlaneGeometry: unknown type');\n }\n\n i2 += 2;\n i3 += 3;\n }\n }\n\n const numVertsAcross = subdivisions1 + 1;\n const indices = new Uint16Array(subdivisions1 * subdivisions2 * 6);\n\n for (let z = 0; z < subdivisions2; z++) {\n for (let x = 0; x < subdivisions1; x++) {\n const index = (z * subdivisions1 + x) * 6;\n // Make triangle 1 of quad.\n indices[index + 0] = (z + 0) * numVertsAcross + x;\n indices[index + 1] = (z + 1) * numVertsAcross + x;\n indices[index + 2] = (z + 0) * numVertsAcross + x + 1;\n\n // Make triangle 2 of quad.\n indices[index + 3] = (z + 1) * numVertsAcross + x;\n indices[index + 4] = (z + 1) * numVertsAcross + x + 1;\n indices[index + 5] = (z + 0) * numVertsAcross + x + 1;\n }\n }\n\n const geometry = {\n indices: {size: 1, value: indices},\n attributes: {\n POSITION: {size: 3, value: positions},\n NORMAL: {size: 3, value: normals},\n TEXCOORD_0: {size: 2, value: texCoords}\n }\n };\n\n // Optionally, unpack indexed geometry\n return unpack ? unpackIndexedGeometry(geometry) : geometry;\n}\n"],"file":"plane-geometry.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/geometries/sphere-geometry.ts"],"names":["uid","Geometry","SphereGeometry","constructor","props","id","indices","attributes","tesselateSphere","nlat","nlong","startLat","endLat","Math","PI","latRange","startLong","endLong","longRange","numVertices","radius","n1","n2","n3","u","v","positions","Float32Array","normals","texCoords","IndexType","Uint32Array","Uint16Array","y","x","index","i2","i3","theta","phi","sinTheta","sin","cosTheta","cos","sinPhi","cosPhi","ux","uy","uz","r","numVertsAround","size","value","POSITION","NORMAL","TEXCOORD_0"],"mappings":"AAAA,SAAQA,GAAR,QAAkB,cAAlB;AACA,OAAOC,QAAP,MAAqB,sBAArB;AAaA,OAAO,MAAMC,cAAN,SAA6BD,QAA7B,CAAsC;AAC3CE,EAAAA,WAAW,CAACC,KAA0B,GAAG,EAA9B,EAAkC;AAC3C,UAAM;AAACC,MAAAA,EAAE,GAAGL,GAAG,CAAC,iBAAD;AAAT,QAAgCI,KAAtC;AACA,UAAM;AAACE,MAAAA,OAAD;AAAUC,MAAAA;AAAV,QAAwBC,eAAe,CAACJ,KAAD,CAA7C;AACA,UAAM,EACJ,GAAGA,KADC;AAEJC,MAAAA,EAFI;AAGJC,MAAAA,OAHI;AAIJC,MAAAA,UAAU,EAAE,EAAC,GAAGA,UAAJ;AAAgB,WAAGH,KAAK,CAACG;AAAzB;AAJR,KAAN;AAMD;;AAV0C;;AAc7C,SAASC,eAAT,CAAyBJ,KAAzB,EAAqD;AACnD,QAAM;AAACK,IAAAA,IAAI,GAAG,EAAR;AAAYC,IAAAA,KAAK,GAAG;AAApB,MAA0BN,KAAhC;AAEA,QAAMO,QAAQ,GAAG,CAAjB;AACA,QAAMC,MAAM,GAAGC,IAAI,CAACC,EAApB;AACA,QAAMC,QAAQ,GAAGH,MAAM,GAAGD,QAA1B;AACA,QAAMK,SAAS,GAAG,CAAlB;AACA,QAAMC,OAAO,GAAG,IAAIJ,IAAI,CAACC,EAAzB;AACA,QAAMI,SAAS,GAAGD,OAAO,GAAGD,SAA5B;AACA,QAAMG,WAAW,GAAG,CAACV,IAAI,GAAG,CAAR,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import {uid} from '@luma.gl/api';\nimport Geometry from '../geometry/geometry';\n\nexport type SphereGeometryProps = {\n id?: string;\n radius?: number;\n nlat?: number;\n nlong?: number;\n attributes?: any\n};\n\n// Primitives inspired by TDL http://code.google.com/p/webglsamples/,\n// copyright 2011 Google Inc. new BSD License\n// (http://www.opensource.org/licenses/bsd-license.php).\nexport class SphereGeometry extends Geometry {\n constructor(props: SphereGeometryProps = {}) {\n const {id = uid('sphere-geometry')} = props;\n const {indices, attributes} = tesselateSphere(props);\n super({\n ...props,\n id,\n indices,\n attributes: {...attributes, ...props.attributes}\n });\n }\n}\n\n/* eslint-disable max-statements, complexity */\nfunction tesselateSphere(props: SphereGeometryProps) {\n const {nlat = 10, nlong = 10} = props;\n\n const startLat = 0;\n const endLat = Math.PI;\n const latRange = endLat - startLat;\n const startLong = 0;\n const endLong = 2 * Math.PI;\n const longRange = endLong - startLong;\n const numVertices = (nlat + 1) * (nlong + 1);\n\n const radius = (n1: number, n2: number, n3: number, u: number, v: number) => props.radius || 1;\n\n const positions = new Float32Array(numVertices * 3);\n const normals = new Float32Array(numVertices * 3);\n const texCoords = new Float32Array(numVertices * 2);\n\n const IndexType = numVertices > 0xffff ? Uint32Array : Uint16Array;\n const indices = new IndexType(nlat * nlong * 6);\n\n // Create positions, normals and texCoords\n for (let y = 0; y <= nlat; y++) {\n for (let x = 0; x <= nlong; x++) {\n const u = x / nlong;\n const v = y / nlat;\n\n const index = x + y * (nlong + 1);\n const i2 = index * 2;\n const i3 = index * 3;\n\n const theta = longRange * u;\n const phi = latRange * v;\n const sinTheta = Math.sin(theta);\n const cosTheta = Math.cos(theta);\n const sinPhi = Math.sin(phi);\n const cosPhi = Math.cos(phi);\n const ux = cosTheta * sinPhi;\n const uy = cosPhi;\n const uz = sinTheta * sinPhi;\n\n const r = radius(ux, uy, uz, u, v);\n\n positions[i3 + 0] = r * ux;\n positions[i3 + 1] = r * uy;\n positions[i3 + 2] = r * uz;\n\n normals[i3 + 0] = ux;\n normals[i3 + 1] = uy;\n normals[i3 + 2] = uz;\n\n texCoords[i2 + 0] = u;\n texCoords[i2 + 1] = 1 - v;\n }\n }\n\n // Create indices\n const numVertsAround = nlong + 1;\n for (let x = 0; x < nlong; x++) {\n for (let y = 0; y < nlat; y++) {\n const index = (x * nlat + y) * 6;\n\n indices[index + 0] = y * numVertsAround + x;\n indices[index + 1] = y * numVertsAround + x + 1;\n indices[index + 2] = (y + 1) * numVertsAround + x;\n\n indices[index + 3] = (y + 1) * numVertsAround + x;\n indices[index + 4] = y * numVertsAround + x + 1;\n indices[index + 5] = (y + 1) * numVertsAround + x + 1;\n }\n }\n\n return {\n indices: {size: 1, value: indices},\n attributes: {\n POSITION: {size: 3, value: positions},\n NORMAL: {size: 3, value: normals},\n TEXCOORD_0: {size: 2, value: texCoords}\n }\n };\n}\n"],"file":"sphere-geometry.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/geometries/truncated-cone-geometry.ts"],"names":["uid","Geometry","INDEX_OFFSETS","x","y","z","makeTruncatedConeGeometry","props","indices","attributes","tesselateTruncatedCone","length","TruncatedConeGeometry","constructor","id","POSITION","size","value","NORMAL","TEXCOORD_0","bottomRadius","topRadius","height","nradial","nvertical","verticalAxis","topCap","bottomCap","extra","numVertices","slant","Math","atan2","msin","sin","mcos","cos","mpi","PI","cosSlant","sinSlant","start","end","vertsAroundEdge","Uint16Array","indexOffset","positions","Float32Array","normals","texCoords","i3","i2","i","v","ringRadius","j","index"],"mappings":"AAAA,SAAQA,GAAR,QAAkB,cAAlB;AACA,OAAOC,QAAP,MAAqB,sBAArB;AAGA,MAAMC,aAAa,GAAG;AACpBC,EAAAA,CAAC,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CADiB;AAEpBC,EAAAA,CAAC,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAFiB;AAGpBC,EAAAA,CAAC,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP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7B,OAAJ,GAAcgC,CAAf,IAAoB,CAAlC;AACA/C,MAAAA,OAAO,CAACgD,KAAK,GAAG,CAAT,CAAP,GAAqBb,eAAe,IAAIS,CAAC,GAAG,CAAR,CAAf,GAA4B,CAA5B,GAAgCG,CAArD;AACA/C,MAAAA,OAAO,CAACgD,KAAK,GAAG,CAAT,CAAP,GAAqBb,eAAe,IAAIS,CAAC,GAAG,CAAR,CAAf,GAA4B,CAA5B,GAAgCG,CAArD;AACA/C,MAAAA,OAAO,CAACgD,KAAK,GAAG,CAAT,CAAP,GAAqBb,eAAe,IAAIS,CAAC,GAAG,CAAR,CAAf,GAA4B,CAA5B,GAAgCG,CAArD;AACA/C,MAAAA,OAAO,CAACgD,KAAK,GAAG,CAAT,CAAP,GAAqBb,eAAe,IAAIS,CAAC,GAAG,CAAR,CAAf,GAA4B,CAA5B,GAAgCG,CAArD;AACA/C,MAAAA,OAAO,CAACgD,KAAK,GAAG,CAAT,CAAP,GAAqBb,eAAe,IAAIS,CAAC,GAAG,CAAR,CAAf,GAA4B,CAA5B,GAAgCG,CAArD;AACA/C,MAAAA,OAAO,CAACgD,KAAK,GAAG,CAAT,CAAP,GAAqBb,eAAe,IAAIS,CAAC,GAAG,CAAR,CAAf,GAA4B,CAA5B,GAAgCG,CAArD;AACD;AACF;;AAED,SAAO;AACL/C,IAAAA,OADK;AAELC,IAAAA,UAAU,EAAE;AACVM,MAAAA,QAAQ,EAAE+B,SADA;AAEV5B,MAAAA,MAAM,EAAE8B,OAFE;AAGV7B,MAAAA,UAAU,EAAE8B;AAHF;AAFP,GAAP;AAQD","sourcesContent":["import {uid} from '@luma.gl/api';\nimport Geometry from '../geometry/geometry';\nimport {GeometryTable} from '../geometry/geometry-table';\n\nconst INDEX_OFFSETS = {\n x: [2, 0, 1],\n y: [0, 1, 2],\n z: [1, 2, 0]\n};\n\nexport type TruncatedConeGeometryProps = {\n topRadius?: number;\n bottomRadius?: number;\n topCap?: boolean;\n bottomCap?: boolean;\n height?: number;\n nradial?: number;\n nvertical?: number;\n verticalAxis?: 'x' | 'y' | 'z';\n};\n\n/**\n * Primitives inspired by TDL http://code.google.com/p/webglsamples/,\n * copyright 2011 Google Inc. new BSD License\n * (http://www.opensource.org/licenses/bsd-license.php).\n */\nexport function makeTruncatedConeGeometry(props?: TruncatedConeGeometryProps): GeometryTable {\n const {indices, attributes} = tesselateTruncatedCone(props);\n return {\n length: indices.length,\n indices,\n attributes\n };\n}\n\nexport class TruncatedConeGeometry extends Geometry {\n constructor(props: TruncatedConeGeometryProps & {id?: string; attributes?: any} = {}) {\n const {id = uid('truncated-code-geometry')} = props;\n const {indices, attributes} = tesselateTruncatedCone(props);\n super({\n ...props,\n id,\n indices,\n attributes: {\n POSITION: {size: 3, value: attributes.POSITION},\n NORMAL: {size: 3, value: attributes.NORMAL},\n TEXCOORD_0: {size: 2, value: attributes.TEXCOORD_0},\n ...props.attributes}\n });\n }\n}\n\n/* eslint-disable max-statements, complexity */\nfunction tesselateTruncatedCone(props: TruncatedConeGeometryProps = {}) {\n const {\n bottomRadius = 0,\n topRadius = 0,\n height = 1,\n nradial = 10,\n nvertical = 10,\n verticalAxis = 'y',\n topCap = false,\n bottomCap = false\n } = props;\n\n const extra = (topCap ? 2 : 0) + (bottomCap ? 2 : 0);\n const numVertices = (nradial + 1) * (nvertical + 1 + extra);\n\n const slant = Math.atan2(bottomRadius - topRadius, height);\n const msin = Math.sin;\n const mcos = Math.cos;\n const mpi = Math.PI;\n const cosSlant = mcos(slant);\n const sinSlant = msin(slant);\n const start = topCap ? -2 : 0;\n const end = nvertical + (bottomCap ? 2 : 0);\n const vertsAroundEdge = nradial + 1;\n\n const indices = new Uint16Array(nradial * (nvertical + extra) * 6);\n const indexOffset = INDEX_OFFSETS[verticalAxis];\n\n const positions = new Float32Array(numVertices * 3);\n const normals = new Float32Array(numVertices * 3);\n const texCoords = new Float32Array(numVertices * 2);\n\n let i3 = 0;\n let i2 = 0;\n for (let i = start; i <= end; i++) {\n let v = i / nvertical;\n let y = height * v;\n let ringRadius;\n\n if (i < 0) {\n y = 0;\n v = 1;\n ringRadius = bottomRadius;\n } else if (i > nvertical) {\n y = height;\n v = 1;\n ringRadius = topRadius;\n } else {\n ringRadius = bottomRadius + (topRadius - bottomRadius) * (i / nvertical);\n }\n if (i === -2 || i === nvertical + 2) {\n ringRadius = 0;\n v = 0;\n }\n y -= height / 2;\n for (let j = 0; j < vertsAroundEdge; j++) {\n const sin = msin((j * mpi * 2) / nradial);\n const cos = mcos((j * mpi * 2) / nradial);\n\n positions[i3 + indexOffset[0]] = sin * ringRadius;\n positions[i3 + indexOffset[1]] = y;\n positions[i3 + indexOffset[2]] = cos * ringRadius;\n\n normals[i3 + indexOffset[0]] = i < 0 || i > nvertical ? 0 : sin * cosSlant;\n normals[i3 + indexOffset[1]] = i < 0 ? -1 : i > nvertical ? 1 : sinSlant;\n normals[i3 + indexOffset[2]] = i < 0 || i > nvertical ? 0 : cos * cosSlant;\n\n texCoords[i2 + 0] = j / nradial;\n texCoords[i2 + 1] = v;\n\n i2 += 2;\n i3 += 3;\n }\n }\n\n for (let i = 0; i < nvertical + extra; i++) {\n for (let j = 0; j < nradial; j++) {\n const index = (i * nradial + j) * 6;\n indices[index + 0] = vertsAroundEdge * (i + 0) + 0 + j;\n indices[index + 1] = vertsAroundEdge * (i + 0) + 1 + j;\n indices[index + 2] = vertsAroundEdge * (i + 1) + 1 + j;\n indices[index + 3] = vertsAroundEdge * (i + 0) + 0 + j;\n indices[index + 4] = vertsAroundEdge * (i + 1) + 1 + j;\n indices[index + 5] = vertsAroundEdge * (i + 1) + 0 + j;\n }\n }\n\n return {\n indices,\n attributes: {\n POSITION: positions,\n NORMAL: normals,\n TEXCOORD_0: texCoords\n }\n };\n}\n"],"file":"truncated-cone-geometry.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"geometry-table.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/geometry/geometry-utils.ts"],"names":["unpackIndexedGeometry","geometry","indices","attributes","vertexCount","value","length","unpackedAttributes","attributeName","attribute","constant","size","unpackedValue","constructor","x","index","i","Object","assign"],"mappings":"AAEA,OAAO,SAASA,qBAAT,CAA+BC,QAA/B,EAA8C;AACnD,QAAM;AAACC,IAAAA,OAAD;AAAUC,IAAAA;AAAV,MAAwBF,QAA9B;;AACA,MAAI,CAACC,OAAL,EAAc;AACZ,WAAOD,QAAP;AACD;;AAED,QAAMG,WAAW,GAAGF,OAAO,CAACG,KAAR,CAAcC,MAAlC;AACA,QAAMC,kBAAuC,GAAG,EAAhD;;AAEA,OAAK,MAAMC,aAAX,IAA4BL,UAA5B,EAAwC;AACtC,UAAMM,SAAS,GAAGN,UAAU,CAACK,aAAD,CAA5B;AACA,UAAM;AAACE,MAAAA,QAAD;AAAWL,MAAAA,KAAX;AAAkBM,MAAAA;AAAlB,QAA0BF,SAAhC;;AACA,QAAIC,QAAQ,IAAI,CAACC,IAAjB,EAAuB;AACrB;AACD;;AACD,UAAMC,aAAa,GAAG,IAAIP,KAAK,CAACQ,WAAV,CAAsBT,WAAW,GAAGO,IAApC,CAAtB;;AACA,SAAK,IAAIG,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGV,WAApB,EAAiC,EAAEU,CAAnC,EAAsC;AACpC,YAAMC,KAAK,GAAGb,OAAO,CAACG,KAAR,CAAcS,CAAd,CAAd;;AACA,WAAK,IAAIE,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGL,IAApB,EAA0BK,CAAC,EAA3B,EAA+B;AAC7BJ,QAAAA,aAAa,CAACE,CAAC,GAAGH,IAAJ,GAAWK,CAAZ,CAAb,GAA8BX,KAAK,CAACU,KAAK,GAAGJ,IAAR,GAAeK,CAAhB,CAAnC;AACD;AACF;;AACDT,IAAAA,kBAAkB,CAACC,aAAD,CAAlB,GAAoC;AAACG,MAAAA,IAAD;AAAON,MAAAA,KAAK,EAAEO;AAAd,KAApC;AACD;;AAED,SAAO;AACLT,IAAAA,UAAU,EAAEc,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBf,UAAlB,EAA8BI,kBAA9B;AADP,GAAP;AAGD","sourcesContent":["// import type Geometry from './geometry';\n\nexport function unpackIndexedGeometry(geometry: any) {\n const {indices, attributes} = geometry;\n if (!indices) {\n return geometry;\n }\n\n const vertexCount = indices.value.length;\n const unpackedAttributes: Record<string, any> = {};\n\n for (const attributeName in attributes) {\n const attribute = attributes[attributeName];\n const {constant, value, size} = attribute;\n if (constant || !size) {\n continue; // eslint-disable-line\n }\n const unpackedValue = new value.constructor(vertexCount * size);\n for (let x = 0; x < vertexCount; ++x) {\n const index = indices.value[x];\n for (let i = 0; i < size; i++) {\n unpackedValue[x * size + i] = value[index * size + i];\n }\n }\n unpackedAttributes[attributeName] = {size, value: unpackedValue};\n }\n\n return {\n attributes: Object.assign({}, attributes, unpackedAttributes)\n };\n}\n"],"file":"geometry-utils.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/geometry/geometry.ts"],"names":["uid","assert","GL","Geometry","constructor","props","TRIANGLES","id","drawMode","attributes","indices","vertexCount","topology","convertToTopology","ArrayBuffer","isView","value","size","attributeName","attributeValue","Object","entries","attribute","_print","isIndexed","undefined","assign","_calculateVertexCount","mode","getVertexCount","getAttributes","_setAttributes","length","Infinity","constant","Math","min","Number","isFinite","POINTS","LINES","LINE_LOOP","LINE_STRIP","TRIANGLE_STRIP","TRIANGLE_FAN","Error","String"],"mappings":";AAEA,SAAQA,GAAR,EAAaC,MAAb,QAA0B,cAA1B;AACA,OAAOC,EAAP,MAAe,oBAAf;AAyCA,eAAe,MAAMC,QAAN,CAAe;AA8B5BC,EAAAA,WAAW,CAACC,KAAoB,GAAG,EAAxB,EAA4B;AAAA;;AAAA,sCAjBH,EAiBG;;AAAA;;AAAA,sCAZPH,EAAE,CAACI,SAYI;;AAAA;;AAAA;;AAAA;;AACrC,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port {uid, assert} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\n\n/**\n * Rendering primitives - \"topology\" specifies how to extract primitives from vertices.\n * @deprecated - use string constants instead\n */\nexport type GLTopology =\n GL.POINTS | // draw single points.\n GL.LINES | // draw lines. Each vertex connects to the one after it.\n GL.LINE_LOOP | // draw lines. Each set of two vertices is treated as a separate line segment.\n GL.LINE_STRIP | // draw a connected group of line segments from the first vertex to the last\n GL.TRIANGLES | // draw triangles. Each set of three vertices creates a separate triangle.\n GL.TRIANGLE_STRIP | // draw a connected group of triangles.\n GL.TRIANGLE_FAN // draw a connected group of triangles.\n ;\n\nexport type GeometryAttribute = {\n size?: number;\n value: TypedArray;\n [key: string]: any\n}\n\nexport type GeometryProps = {\n id?: string;\n attributes?: Record<string, GeometryAttribute | TypedArray>,\n indices?: GeometryAttribute | TypedArray;\n vertexCount?: number;\n /** Determines how vertices are read from the 'vertex' attributes */\n topology?: 'point-list' | 'line-list' | 'line-strip' | 'triangle-list' | 'triangle-strip';\n /** @deprecated */\n drawMode?: GLTopology;\n};\n\ntype GeometryAttributes = {\n POSITION: GeometryAttribute,\n NORMAL: GeometryAttribute,\n TEXCOORD_0: GeometryAttribute,\n COLOR_0?: GeometryAttribute,\n indices?: {size?: number, value: Uint32Array | Uint16Array};\n};\n\nexport default class Geometry {\n /** @deprecated */\n static DRAW_MODE = {\n POINTS: GL.POINTS, // draw single points.\n LINES: GL.LINES, // draw lines. Each vertex connects to the one after it.\n LINE_LOOP: GL.LINE_LOOP, // draw lines. Each set of two vertices is treated as a separate line segment.\n LINE_STRIP: GL.LINE_STRIP, // draw a connected group of line segments from the first vertex to the last\n TRIANGLES: GL.TRIANGLES, // draw triangles. Each set of three vertices creates a separate triangle.\n TRIANGLE_STRIP: GL.TRIANGLE_STRIP, // draw a connected group of triangles.\n TRIANGLE_FAN: GL.TRIANGLE_FAN // draw a connected group of triangles.\n };\n\n readonly id: string;\n userData: Record<string, unknown> = {};\n\n /** Determines how vertices are read from the 'vertex' attributes */\n topology?: PrimitiveTopology;\n /** @deprecated */\n readonly drawMode: GLTopology = GL.TRIANGLES;\n\n readonly vertexCount: number;\n readonly attributes: {\n POSITION: GeometryAttribute,\n NORMAL: GeometryAttribute,\n TEXCOORD_0: GeometryAttribute,\n COLOR_0?: GeometryAttribute,\n [key: string]: GeometryAttribute | undefined\n };\n readonly indices?: Uint16Array | Uint32Array;\n\n constructor(props: GeometryProps = {}) {\n const {\n id = uid('geometry'),\n drawMode = GL.TRIANGLES,\n attributes = {},\n indices = null,\n vertexCount = null\n } = props;\n\n this.id = id;\n this.drawMode = drawMode;\n this.topology = props.topology || convertToTopology(drawMode);\n\n if (indices) {\n // @ts-expect-error\n this.indices = ArrayBuffer.isView(indices) ? {value: indices, size: 1} : indices;\n }\n\n // @ts-expect-error\n this.attributes = {};\n\n for (const [attributeName, attributeValue] of Object.entries(attributes)) {\n\n // Wrap \"unwrapped\" arrays and try to autodetect their type\n const attribute: GeometryAttribute = ArrayBuffer.isView(attributeValue) ? {value: attributeValue} : attributeValue;\n\n assert(\n ArrayBuffer.isView(attribute.value),\n `${this._print(attributeName)}: must be typed array or object with value as typed array`\n );\n\n if ((attributeName === 'POSITION' || attributeName === 'positions') && !attribute.size) {\n attribute.size = 3;\n }\n\n // Move indices to separate field\n if (attributeName === 'indices') {\n assert(!this.indices);\n // @ts-expect-error\n this.indices = attribute;\n } else {\n this.attributes[attributeName] = attribute;\n }\n }\n\n // @ts-expect-error\n if (this.indices && this.indices.isIndexed !== undefined) {\n this.indices = Object.assign({}, this.indices);\n // @ts-expect-error\n delete this.indices.isIndexed;\n }\n\n this.vertexCount = vertexCount || this._calculateVertexCount(this.attributes, this.indices);\n }\n\n /** @deprecated Use string topology constants instead */\n get mode() {\n return this.drawMode;\n }\n\n getVertexCount(): number {\n return this.vertexCount;\n }\n\n // Return an object with all attributes plus indices added as a field.\n getAttributes(): GeometryAttributes {\n // @ts-expect-error Geometry types are a mess\n return this.indices ? {indices: this.indices, ...this.attributes} : this.attributes;\n }\n\n // PRIVATE\n\n _print(attributeName: string): string {\n return `Geometry ${this.id} attribute ${attributeName}`;\n }\n\n // GeometryAttribute\n // value: typed array\n // type: indices, vertices, uvs\n // size: elements per vertex\n // target: WebGL buffer type (string or constant)\n _setAttributes(attributes: Record<string, GeometryAttribute>, indices: any): this {\n\n return this;\n }\n\n _calculateVertexCount(attributes: any, indices: any): number {\n if (indices) {\n return indices.value.length;\n }\n let vertexCount = Infinity;\n for (const attributeName in attributes) {\n const attribute = attributes[attributeName];\n const {value, size, constant} = attribute;\n if (!constant && value && size >= 1) {\n vertexCount = Math.min(vertexCount, value.length / size);\n }\n }\n\n assert(Number.isFinite(vertexCount));\n return vertexCount;\n }\n}\n\nfunction convertToTopology(drawMode: GLTopology): PrimitiveTopology {\n switch (drawMode) {\n case GL.POINTS: return 'point-list'; // draw single points.\n case GL.LINES: return 'line-list'; // draw lines. Each vertex connects to the one after it.\n case GL.LINE_STRIP: return 'line-strip'; // draw a connected group of line segments from the first vertex to the last\n case GL.TRIANGLES: return 'triangle-list'; // draw triangles. Each set of three vertices creates a separate triangle.\n case GL.TRIANGLE_STRIP: return 'triangle-strip'; // draw a connected group of triangles.\n\n case GL.TRIANGLE_FAN: return 'triangle-fan'; // draw a connected group of triangles.\n case GL.LINE_LOOP: return 'line-loop'; // draw lines. Each set of two vertices is treated as a separate line segment.\n default:\n throw new Error(String(drawMode));\n }\n}\n"],"file":"geometry.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"primitive-utils.js"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":["Timeline","KeyFrames","AnimationLoopTemplate","AnimationLoop","makeAnimationLoop","Model","PipelineFactory","default","Geometry","ConeGeometry","CubeGeometry","CylinderGeometry","IcoSphereGeometry","PlaneGeometry","SphereGeometry","TruncatedConeGeometry"],"mappings":"AAGA,SAAQA,QAAR,QAAuB,sBAAvB;AACA,SAAQC,SAAR,QAAwB,wBAAxB;AAGA,SAAQC,qBAAR,QAAoC,8BAApC;AAGA,SAAQC,aAAR,QAA4B,iCAA5B;AAGA,SAAQC,iBAAR,QAAgC,sCAAhC;AAGA,SAAQC,KAAR,QAAoB,aAApB;AAEA,SAAQC,eAAR,QAA8B,wBAA9B;AAMA,SAAQC,OAAO,IAAIC,QAAnB,QAAkC,qBAAlC;AAIA,SAAQC,YAAR,QAA2B,4BAA3B;AAEA,SAAQC,YAAR,QAA2B,4BAA3B;AAEA,SAAQC,gBAAR,QAA+B,gCAA/B;AAEA,SAAQC,iBAAR,QAAgC,kCAAhC;AAEA,SAAQC,aAAR,QAA4B,6BAA5B;AAEA,SAAQC,cAAR,QAA6B,8BAA7B;AAEA,SAAQC,qBAAR,QAAoC,sCAApC","sourcesContent":["// luma.gl Engine API\n\n// Animation\nexport {Timeline} from './animation/timeline';\nexport {KeyFrames} from './animation/key-frames';\nexport type {AnimationProps} from './animation-loop/animation-props';\n\nexport {AnimationLoopTemplate} from './animation-loop/render-loop';\n\nexport type {AnimationLoopProps} from './animation-loop/animation-loop';\nexport {AnimationLoop} from './animation-loop/animation-loop';\n\nexport type {MakeAnimationLoopProps} from './animation-loop/make-animation-loop';\nexport {makeAnimationLoop} from './animation-loop/make-animation-loop';\n\nexport type {ModelProps} from './lib/model';\nexport {Model} from './lib/model';\n\nexport {PipelineFactory} from './lib/pipeline-factory';\n\n// Utils\n// export {default as ClipSpace} from './lib/clip-space';\n\n// Geometries\nexport {default as Geometry} from './geometry/geometry';\n\n// Primitives\nexport type {ConeGeometryProps} from './geometries/cone-geometry';\nexport {ConeGeometry} from './geometries/cone-geometry';\nexport type {CubeGeometryProps} from './geometries/cube-geometry';\nexport {CubeGeometry} from './geometries/cube-geometry';\nexport type {CylinderGeometryProps} from './geometries/cylinder-geometry';\nexport {CylinderGeometry} from './geometries/cylinder-geometry';\nexport type {IcoSphereGeometryProps} from './geometries/ico-sphere-geometry';\nexport {IcoSphereGeometry} from './geometries/ico-sphere-geometry';\nexport type {PlaneGeometryProps} from './geometries/plane-geometry';\nexport {PlaneGeometry} from './geometries/plane-geometry';\nexport type {SphereGeometryProps} from './geometries/sphere-geometry';\nexport {SphereGeometry} from './geometries/sphere-geometry';\nexport type {TruncatedConeGeometryProps} from './geometries/truncated-cone-geometry';\nexport {TruncatedConeGeometry} from './geometries/truncated-cone-geometry';\n\n"],"file":"index.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"clip-space.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/model-utils.ts"],"names":["Buffer","assert","GLTF_TO_LUMA_ATTRIBUTE_MAP","POSITION","NORMAL","COLOR_0","TEXCOORD_0","TEXCOORD_1","TEXCOORD_2","getIndexBufferFromGeometry","device","geometry","indices","undefined","data","value","Uint16Array","Uint32Array","createBuffer","usage","INDEX","getAttributeBuffersFromGeometry","buffers","name","attribute","Object","entries","attributes","remappedName","mapAttributeName","constant","Error","typedArray","id"],"mappings":"AAAA,SAAgBA,MAAhB,EAAwBC,MAAxB,QAAqC,cAArC;AAIA,MAAMC,0BAA0B,GAAG;AACjCC,EAAAA,QAAQ,EAAE,WADuB;AAEjCC,EAAAA,MAAM,EAAE,SAFyB;AAGjCC,EAAAA,OAAO,EAAE,QAHwB;AAIjCC,EAAAA,UAAU,EAAE,WAJqB;AAKjCC,EAAAA,UAAU,EAAE,YALqB;AAMjCC,EAAAA,UAAU,EAAE;AANqB,CAAnC;AAmDA,OAAO,SAASC,0BAAT,CAAoCC,MAApC,EAAoDC,QAApD,EAA4F;AACjG,MAAI,CAACA,QAAQ,CAACC,OAAd,EAAuB;AACrB,WAAOC,SAAP;AACD;;AAGD,QAAMC,IAAI,GAAGH,QAAQ,CAACC,OAAT,CAAiBG,KAAjB,IAA0BJ,QAAQ,CAACC,OAAhD;AACAX,EAAAA,MAAM,CACJa,IAAI,YAAYE,WAAhB,IAA+BF,IAAI,YAAYG,WAD3C,EAEJ,uDAFI,CAAN;AAIA,SAAOP,MAAM,CAACQ,YAAP,CAAoB;AAACC,IAAAA,KAAK,EAAEnB,MAAM,CAACoB,KAAf;AAAsBN,IAAAA;AAAtB,GAApB,CAAP;AACD;AAED,OAAO,SAASO,+BAAT,CAAyCX,MAAzC,EAAyDC,QAAzD,EAAqG;AAC1G,QAAMW,OAA+B,GAAG,EAAxC;;AAEA,OAAK,MAAM,CAACC,IAAD,EAAOC,SAAP,CAAX,IAAgCC,MAAM,CAACC,OAAP,CAAef,QAAQ,CAACgB,UAAxB,CAAhC,EAAqE;AACnE,UAAMC,YAAY,GAAGC,gBAAgB,CAACN,IAAD,CAArC;;AACA,QAAIC,SAAJ,aAAIA,SAAJ,eAAIA,SAAS,CAAEM,QAAf,EAAyB;AACvB,YAAM,IAAIC,KAAJ,CAAU,mCAAV,CAAN;AACD,KAFD,MAEO;AACL,YAAMC,UAAU,GAAGR,SAAH,aAAGA,SAAH,uBAAGA,SAAS,CAAET,KAA9B;AACAO,MAAAA,OAAO,CAACM,YAAD,CAAP,GAAwBlB,MAAM,CAACQ,YAAP,CAAoB;AAACJ,QAAAA,IAAI,EAAEkB,UAAP;AAAmBC,QAAAA,EAAE,YAAKL,YAAL;AAArB,OAApB,CAAxB;AACD;AACF;;AAED,SAAON,OAAP;AACD;;AAED,SAASO,gBAAT,CAA0BN,IAA1B,EAAgD;AAE9C,SAAOrB,0BAA0B,CAACqB,IAAD,CAA1B,IAAoCA,IAA3C;AACD","sourcesContent":["import {Device, Buffer, assert} from '@luma.gl/api';\nimport type Geometry from '../geometry/geometry';\n\n// Support for mapping new geometries with glTF attribute names to \"classic\" luma.gl shader names\nconst GLTF_TO_LUMA_ATTRIBUTE_MAP = {\n POSITION: 'positions',\n NORMAL: 'normals',\n COLOR_0: 'colors',\n TEXCOORD_0: 'texCoords',\n TEXCOORD_1: 'texCoords1',\n TEXCOORD_2: 'texCoords2'\n};\n\n/*\nexport function getAttributeLayoutsFromGeometry(geometry: Geometry) {\n const layouts: Record<string, {}> = {};\n let indices = geometry.indices;\n\n for (const [name, attribute] of Object.entries(geometry.attributes)) {\n const remappedName = mapAttributeName(name);\n\n if (attribute.constant) {\n throw new Error('constant attributes not supported');\n } else {\n const typedArray = attribute.value;\n // Create accessor by copying the attribute and removing `value``\n const accessor = {...attribute};\n delete accessor.value;\n buffers[remappedName] = [device.createBuffer(typedArray), accessor];\n\n inferAttributeAccessor(name, accessor);\n }\n }\n}\n\nexport class Table {\n length: number;\n // columns: Record<string, TypedArray> = {};\n}\n\nexport class GPUTable {\n length: number;\n columns: Record<string, Buffer> = {};\n}\n\nexport function convertTableToGPUTable(table: Table) {\n // for (const ) {}\n}\n\nexport function renameTableColumns(table: Table, map: (name: string) => string) {\n const newColumns = table.columns.reduce()\n table.clone();\n}\n*/\n\nexport function getIndexBufferFromGeometry(device: Device, geometry: Geometry): Buffer | undefined {\n if (!geometry.indices) {\n return undefined;\n }\n\n // @ts-expect-error\n const data = geometry.indices.value || geometry.indices;\n assert(\n data instanceof Uint16Array || data instanceof Uint32Array,\n 'attribute array for \"indices\" must be of integer type'\n );\n return device.createBuffer({usage: Buffer.INDEX, data});\n}\n\nexport function getAttributeBuffersFromGeometry(device: Device, geometry: Geometry): Record<string, Buffer> {\n const buffers: Record<string, Buffer> = {};\n\n for (const [name, attribute] of Object.entries(geometry.attributes)) {\n const remappedName = mapAttributeName(name);\n if (attribute?.constant) {\n throw new Error('constant attributes not supported');\n } else {\n const typedArray = attribute?.value;\n buffers[remappedName] = device.createBuffer({data: typedArray, id: `${remappedName}-buffer`});\n }\n }\n\n return buffers;\n}\n\nfunction mapAttributeName(name: string): string {\n // @ts-ignore-error\n return GLTF_TO_LUMA_ATTRIBUTE_MAP[name] || name;\n}\n\n/*\n// Check for well known attribute names\n// eslint-disable-next-line complexity\nexport function inferAttributeAccessor(attributeName, attribute) {\n let category;\n switch (attributeName) {\n case 'texCoords':\n case 'texCoord1':\n case 'texCoord2':\n case 'texCoord3':\n category = 'uvs';\n break;\n case 'vertices':\n case 'positions':\n case 'normals':\n case 'pickingColors':\n category = 'vectors';\n break;\n default:\n }\n\n // Check for categorys\n switch (category) {\n case 'vectors':\n attribute.size = attribute.size || 3;\n break;\n case 'uvs':\n attribute.size = attribute.size || 2;\n break;\n default:\n }\n\n assert(Number.isFinite(attribute.size), `attribute ${attributeName} needs size`);\n}\n*/\n"],"file":"model-utils.js"}
|
package/dist/lib/model.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/model.ts"],"names":["RenderPipeline","getAttributeBuffersFromGeometry","getIndexBufferFromGeometry","PipelineFactory","DEFAULT_MODEL_PROPS","_DEFAULT_PROPS","vs","fs","id","handle","undefined","userData","modules","moduleSettings","geometry","Model","constructor","device","props","Error","getShaderSource","vertexCount","topology","pipelineFactory","getDefaultPipelineFactory","pipeline","getUniforms","createRenderPipeline","parameters","layout","_getModuleUniforms","_setGeometry","setUniforms","setProps","destroy","draw","renderPass","instanceCount","indices","setIndexBuffer","attributes","setAttributes","bindings","setBindings","uniforms","updateModuleSettings","Object","assign","geometryBuffers","indexBuffer","shader","info","type","wgsl","glsl"],"mappings":";AAGA,SAAQA,cAAR,QAA6B,cAA7B;AAGA,SAAQC,+BAAR,EAAyCC,0BAAzC,QAA0E,eAA1E;AACA,SAAQC,eAAR,QAA8B,oBAA9B;AAWA,MAAMC,mBAAyC,GAAG,EAChD,GAAGJ,cAAc,CAACK,cAD8B;AAEhDC,EAAAA,EAAE,EAAE,IAF4C;AAGhDC,EAAAA,EAAE,EAAE,IAH4C;AAIhDC,EAAAA,EAAE,EAAE,SAJ4C;AAKhDC,EAAAA,MAAM,EAAEC,SALwC;AAMhDC,EAAAA,QAAQ,EAAE,EANsC;AAOhDC,EAAAA,OAAO,EAAE,EAPuC;AAQhDC,EAAAA,cAAc,EA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iB;AACf,WAAKV,cAAL,CAAoBU,WAApB;AACD;AACF;;AAhIgB;;AAoInB,SAAS7B,eAAT,CAAyBH,MAAzB,EAAyCiC,MAAzC,EAAkG;AAEhG,MAAI,OAAOA,MAAP,KAAkB,QAAtB,EAAgC;AAC9B,WAAOA,MAAP;AACD;;AAED,UAAQjC,MAAM,CAACkC,IAAP,CAAYC,IAApB;AACE,SAAK,QAAL;AACE,UAAIF,MAAJ,aAAIA,MAAJ,eAAIA,MAAM,CAAEG,IAAZ,EAAkB;AAChB,eAAOH,MAAM,CAACG,IAAd;AACD;;AACD,YAAM,IAAIlC,KAAJ,CAAU,sCAAV,CAAN;;AAEF;AACE,UAAI+B,MAAJ,aAAIA,MAAJ,eAAIA,MAAM,CAAEI,IAAZ,EAAkB;AAChB,eAAOJ,MAAM,CAACI,IAAd;AACD;;AACD,YAAM,IAAInC,KAAJ,CAAU,qCAAV,CAAN;AAXJ;AAaD","sourcesContent":["// luma.gl, MIT license\n\nimport type {Device, Buffer, RenderPipelineProps, RenderPass, Binding, PrimitiveTopology} from '@luma.gl/api';\nimport {RenderPipeline} from '@luma.gl/api';\nimport type { ShaderModule } from '@luma.gl/shadertools';\nimport type Geometry from '../geometry/geometry';\nimport {getAttributeBuffersFromGeometry, getIndexBufferFromGeometry} from './model-utils';\nimport {PipelineFactory} from './pipeline-factory';\n\nexport type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {\n // Model also accepts a string\n vs?: {glsl?: string; wgsl?: string} | string | null;\n fs?: {glsl?: string; wgsl?: string} | string | null;\n modules?: ShaderModule[];\n moduleSettings?: Record<string, Record<string, any>>;\n geometry?: Geometry | null;\n};\n\nconst DEFAULT_MODEL_PROPS: Required<ModelProps> = {\n ...RenderPipeline._DEFAULT_PROPS,\n vs: null,\n fs: null,\n id: 'unnamed',\n handle: undefined,\n userData: {},\n modules: [],\n moduleSettings: {},\n geometry: null\n};\n\n/** v9 API */\nexport class Model {\n readonly device: Device;\n readonly pipeline: RenderPipeline;\n readonly id: string;\n readonly vs: string;\n readonly fs: string | null = null;\n readonly topology: PrimitiveTopology;\n readonly vertexCount;\n props: Required<ModelProps>;\n\n private _getModuleUniforms: (props?: Record<string, Record<string, any>>) => Record<string, any>;\n\n constructor(device: Device, props: ModelProps) {\n this.props = {...DEFAULT_MODEL_PROPS, ...props};\n props = this.props;\n this.id = this.props.id;\n this.device = device;\n\n // Create the pipeline\n if (!props.vs) {\n throw new Error('no vertex shader');\n }\n this.vs = getShaderSource(this.device, props.vs);\n if (props.fs) {\n this.fs = getShaderSource(this.device, props.fs);\n }\n\n this.vertexCount = this.props.vertexCount;\n this.topology = this.props.topology;\n\n if (this.props.geometry) {\n this.vertexCount = this.props.geometry.vertexCount;\n this.topology = this.props.geometry.topology || 'triangle-list';\n }\n\n const pipelineFactory = PipelineFactory.getDefaultPipelineFactory(this.device);\n const {pipeline, getUniforms} = pipelineFactory.createRenderPipeline({\n ...this.props,\n vs: this.vs,\n fs: this.fs,\n topology: this.topology,\n parameters: props.parameters,\n layout: props.layout\n });\n\n this.pipeline = pipeline;\n this._getModuleUniforms = getUniforms;\n\n if (this.props.geometry) {\n this._setGeometry(this.props.geometry);\n }\n this.setUniforms(this._getModuleUniforms()) // Get all default module uniforms\n this.setProps(this.props);\n }\n\n destroy(): void {\n this.pipeline.destroy();\n }\n\n draw(renderPass?: RenderPass): this {\n this.pipeline.draw({\n renderPass,\n vertexCount: this.vertexCount,\n instanceCount: this.props.instanceCount\n });\n return this;\n }\n\n setProps(props: ModelProps): this {\n if (props.indices) {\n this.setIndexBuffer(props.indices);\n }\n if (props.attributes) {\n this.setAttributes(props.attributes);\n }\n if (props.bindings) {\n this.setBindings(props.bindings);\n }\n if (props.uniforms) {\n this.setUniforms(props.uniforms);\n }\n if (props.moduleSettings) {\n this.updateModuleSettings(props.moduleSettings);\n }\n return this;\n }\n\n updateModuleSettings(props: Record<string, any>): this {\n const uniforms = this._getModuleUniforms(props);\n this.setUniforms(uniforms);\n return this;\n }\n\n setIndexBuffer(indices: Buffer): this {\n this.pipeline.setIndexBuffer(indices);\n // this._indices = indices;\n return this;\n }\n\n setAttributes(attributes: Record<string, Buffer>): this {\n this.pipeline.setAttributes(attributes);\n Object.assign(this.props.attributes, attributes);\n return this;\n }\n\n /** Set the bindings */\n setBindings(bindings: Record<string, Binding>): this {\n this.pipeline.setBindings(bindings);\n Object.assign(this.props.bindings, bindings);\n return this;\n }\n\n setUniforms(uniforms: Record<string, any>): this {\n this.pipeline.setUniforms(uniforms);\n Object.assign(this.props.uniforms, uniforms);\n return this;\n }\n\n _setGeometry(geometry: Geometry): void {\n // this._deleteGeometryBuffers();\n\n const geometryBuffers = getAttributeBuffersFromGeometry(this.device, geometry);\n this.setAttributes(geometryBuffers);\n\n const indexBuffer = getIndexBufferFromGeometry(this.device, geometry);\n if (indexBuffer) {\n this.setIndexBuffer(indexBuffer);\n }\n }\n}\n\n/** Create a shader from the different overloads */\nfunction getShaderSource(device: Device, shader: string | {glsl?: string; wgsl?: string}): string {\n // TODO - detect WGSL/GLSL and throw an error if not supported\n if (typeof shader === 'string') {\n return shader;\n }\n\n switch (device.info.type) {\n case 'webgpu':\n if (shader?.wgsl) {\n return shader.wgsl;\n }\n throw new Error('WebGPU does not support GLSL shaders');\n\n default:\n if (shader?.glsl) {\n return shader.glsl;\n }\n throw new Error('WebGL does not support WGSL shaders');\n }\n}\n"],"file":"model.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/pipeline-factory.ts"],"names":["assembleShaders","DEFAULT_RENDER_PIPELINE_OPTIONS","vs","fs","modules","defines","inject","transpileToGLSL100","layout","varyings","bufferMode","topology","parameters","PipelineFactory","getDefaultPipelineFactory","device","defaultPipelineFactory","constructor","addDefaultModule","module","_defaultModules","find","m","name","push","stateHash","removeDefaultModule","moduleName","filter","addShaderHook","hook","opts","Object","assign","_hookFunctions","createRenderPipeline","options","props","_getModuleList","hash","_hashRenderPipeline","_pipelineCache","pipeline","getUniforms","_createRenderPipeline","_getUniforms","x","_useCounts","release","destroy","platformInfo","gpu","info","features","Error","assembled","hookFunctions","createShader","stage","source","vsHash","_getHash","fsHash","moduleHashes","map","sort","varyingHashes","v","defineKeys","keys","injectKeys","defineHashes","injectHashes","key","String","parameterHash","JSON","stringify","join","_hashes","undefined","_hashCounter","appModules","Array","length","seen","count","i","len"],"mappings":";AAGA,SAAQA,eAAR,QAA8B,sBAA9B;AA+BA,MAAMC,+BAAmE,GAAG;AAC1EC,EAAAA,EAAE,EAAE,EADsE;AAE1EC,EAAAA,EAAE,EAAE,EAFsE;AAG1EC,EAAAA,OAAO,EAAE,EAHiE;AAI1EC,EAAAA,OAAO,EAAE,EAJiE;AAK1EC,EAAAA,MAAM,EAAE,EALkE;AAM1EC,EAAAA,kBAAkB,EAAE,KANsD;AAO1EC,EAAAA,MAAM,EAAE,IAPkE;AAS1EC,EAAAA,QAAQ,EAAE,EATgE;AAU1EC,EAAAA,UAAU,EAAE,MAV8D;AAW1EC,EAAAA,QAAQ,EAAE,eAXgE;AAY1EC,EAAAA,UAAU,EAAE;AAZ8D,CAA5E;AAkBA,OAAO,MAAMC,eAAN,CAAsB;AAeK,SAAzBC,yBAAyB,CAACC,MAAD,EAAkC;AAEhEA,IAAAA,MAAM,CAACC,sBAAP,GAAgCD,MAAM,CAACC,sBAAP,IAAiC,IAAIH,eAAJ,CAAoBE,MAApB,CAAjE;AAEA,WAAOA,MAAM,CAACC,sBAAd;AACD;;AAEDC,EAAAA,WAAW,CAACF,MAAD,EAAiB;AAAA;;AAAA,uCAnBR,CAmBQ;;AAAA,0CAlBG,CAkBH;;AAAA,qCAjBuB,EAiBvB;;AAAA,wCAhB0B,EAgB1B;;AAAA,4CAdsC,EActC;;AAAA,0CAZqC,EAYrC;;AAAA,4CAXa,EAWb;;AAAA,6CAVK,EAUL;;AAC1B,SAAKA,MAAL,GAAcA,MAAd;AACD;;AAEDG,EAAAA,gBAAgB,CAACC,MAAD,EAA6B;AAC3C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ACI,IAApB;;AACA,UAAI,CAAC8D,IAAI,CAAC9D,IAAD,CAAT,EAAiB;AACfnB,QAAAA,OAAO,CAACkF,KAAK,EAAN,CAAP,GAAmBnE,MAAnB;AACAkE,QAAAA,IAAI,CAAC9D,IAAD,CAAJ,GAAa,IAAb;AACD;AACF;;AAEDnB,IAAAA,OAAO,CAACgF,MAAR,GAAiBE,KAAjB;AAEA,WAAOlF,OAAP;AACD;;AApL0B","sourcesContent":["import type {RenderPipelineParameters, PrimitiveTopology, ShaderLayout} from '@luma.gl/api';\nimport {Device, RenderPipeline} from '@luma.gl/api/';\nimport type { ShaderModule } from '@luma.gl/shadertools';\nimport {assembleShaders} from '@luma.gl/shadertools';\n\nexport type GetRenderPipelineOptions = {\n vs: string;\n fs: string | null;\n topology: PrimitiveTopology;\n layout?: ShaderLayout | null;\n parameters?: RenderPipelineParameters;\n\n modules?: ShaderModule[];\n defines?: Record<string, string | number | boolean>;\n inject?: Record<string, string>;\n transpileToGLSL100?: boolean;\n\n varyings?: string[];\n bufferMode?: number, \n};\n\nexport type GetComputePipelineOptions = {\n cs: string;\n parameters?: RenderPipelineParameters;\n\n modules?: ShaderModule[];\n defines?: Record<string, string>;\n inject?: Record<string, string>;\n transpileToGLSL100?: boolean;\n\n varyings?: string[];\n bufferMode?: number;\n};\n\nconst DEFAULT_RENDER_PIPELINE_OPTIONS: Required<GetRenderPipelineOptions> = {\n vs: '',\n fs: '',\n modules: [],\n defines: {},\n inject: {},\n transpileToGLSL100: false,\n layout: null,\n\n varyings: [],\n bufferMode: 0x8c8d, // // varyings/bufferMode for xform feedback, 0x8c8d: SEPARATE_ATTRIBS\n topology: 'triangle-list',\n parameters: {} \n};\n\ntype GetUniformsFunc = (props?: Record<string, any>) => Record<string, any>;\n\n/** Efficiently create shared pipelines with varying parameters */\nexport class PipelineFactory {\n readonly device: Device;\n\n stateHash: number = 0; // Used to change hashing if hooks are modified\n private _hashCounter: number = 0;\n private readonly _hashes: Record<string, number> = {};\n private readonly _useCounts: Record<string, number> = {};\n\n private readonly _pipelineCache: Record<string, RenderPipeline> = {};\n\n private readonly _getUniforms: Record<string, GetUniformsFunc> = {};\n private readonly _hookFunctions: any[] = [];\n private _defaultModules: any[] = [];\n // private readonly _registeredModules = {}; // TODO: Remove? This isn't used anywhere in luma.gl\n\n static getDefaultPipelineFactory(device: Device): PipelineFactory {\n // @ts-expect-error Add to device\n device.defaultPipelineFactory = device.defaultPipelineFactory || new PipelineFactory(device);\n // @ts-expect-error Add to device\n return device.defaultPipelineFactory;\n }\n\n constructor(device: Device) {\n this.device = device;\n }\n\n addDefaultModule(module: ShaderModule): void {\n if (!this._defaultModules.find((m) => m.name === (typeof module === 'string' ? module : module.name))) {\n this._defaultModules.push(module);\n }\n this.stateHash++;\n }\n\n removeDefaultModule(module: ShaderModule): void {\n const moduleName = typeof module === 'string' ? module : module.name;\n this._defaultModules = this._defaultModules.filter((m) => m.name !== moduleName);\n this.stateHash++;\n }\n\n addShaderHook(hook: string, opts?: any): void {\n if (opts) {\n hook = Object.assign(opts, {hook});\n }\n this._hookFunctions.push(hook);\n this.stateHash++;\n }\n\n createRenderPipeline(options: GetRenderPipelineOptions): {\n pipeline: RenderPipeline;\n getUniforms: GetUniformsFunc;\n } {\n const props: Required<GetRenderPipelineOptions> = {...DEFAULT_RENDER_PIPELINE_OPTIONS, ...options};\n\n const modules = this._getModuleList(props.modules); // Combine with default modules\n\n const hash = this._hashRenderPipeline({...props, modules});\n\n if (!this._pipelineCache[hash]) {\n const {pipeline, getUniforms} = this._createRenderPipeline({...props, modules});\n pipeline.hash = hash;\n this._pipelineCache[hash] = pipeline;\n this._getUniforms[hash] = getUniforms || ((x?: unknown) => ({}));\n this._useCounts[hash] = 0;\n }\n\n this._useCounts[hash]++;\n\n return {\n pipeline: this._pipelineCache[hash],\n getUniforms: this._getUniforms[hash]\n };\n }\n\n release(pipeline: RenderPipeline): void {\n const hash = pipeline.hash;\n this._useCounts[hash]--;\n if (this._useCounts[hash] === 0) {\n this._pipelineCache[hash].destroy();\n delete this._pipelineCache[hash];\n delete this._getUniforms[hash];\n delete this._useCounts[hash];\n }\n }\n\n getUniforms(pipeline: RenderPipeline) {\n return this._getUniforms[pipeline.hash] || null;\n }\n\n // PRIVATE\n\n _createRenderPipeline(props: GetRenderPipelineOptions): {\n pipeline: RenderPipeline,\n getUniforms: GetUniformsFunc\n } {\n const platformInfo = {\n gpu: this.device.info.gpu,\n features: this.device.features\n };\n\n if (!props.fs) {\n throw new Error('fs');\n }\n\n const assembled = assembleShaders(platformInfo, {...props, fs: props.fs, hookFunctions: this._hookFunctions});\n\n const pipeline = this.device.createRenderPipeline({\n ...props,\n vs: this.device.createShader({stage: 'vertex', source: assembled.vs}),\n fs: assembled.fs ? this.device.createShader({stage: 'fragment', source: assembled.fs}) : null,\n });\n\n return {pipeline, getUniforms: assembled.getUniforms};\n }\n\n /** Calculate a hash based on all the inputs for a render pipeline */\n _hashRenderPipeline(props: GetRenderPipelineOptions): string {\n const {modules = [], varyings = [], defines = {}, inject = {}, parameters = {}} = props;\n const vsHash = this._getHash(props.vs);\n const fsHash = props.fs ? this._getHash(props.fs) : 0;\n\n const moduleHashes = modules.map((m) => this._getHash(typeof m === 'string' ? m : m.name)).sort();\n const varyingHashes = varyings.map((v) => this._getHash(v));\n\n const defineKeys = Object.keys(defines).sort();\n const injectKeys = Object.keys(inject).sort();\n const defineHashes: number[] = [];\n const injectHashes: number[] = [];\n\n for (const key of defineKeys) {\n defineHashes.push(this._getHash(key));\n defineHashes.push(this._getHash(String(defines[key])));\n }\n\n for (const key of injectKeys) {\n injectHashes.push(this._getHash(key));\n injectHashes.push(this._getHash(inject[key]));\n }\n\n // TODO - hash parameters!\n const parameterHash = JSON.stringify(parameters);\n\n return `${vsHash}/${fsHash}D${defineHashes.join('/')}M${moduleHashes.join(\n '/'\n )}I${injectHashes.join('/')}V${varyingHashes.join('/')}H${this.stateHash}B${props.bufferMode}${\n props.transpileToGLSL100 ? 'T' : ''\n }P${parameterHash}`;\n }\n\n _getHash(key: string): number {\n if (this._hashes[key] === undefined) {\n this._hashes[key] = this._hashCounter++;\n }\n return this._hashes[key];\n }\n\n // Dedupe and combine with default modules\n _getModuleList(appModules: ShaderModule[] = []): ShaderModule[] {\n const modules = new Array(this._defaultModules.length + appModules.length);\n const seen: Record<string, boolean> = {};\n let count = 0;\n\n for (let i = 0, len = this._defaultModules.length; i < len; ++i) {\n const module = this._defaultModules[i];\n const name = module.name;\n modules[count++] = module;\n seen[name] = true;\n }\n\n for (let i = 0, len = appModules.length; i < len; ++i) {\n const module = appModules[i];\n const name = module.name;\n if (!seen[name]) {\n modules[count++] = module;\n seen[name] = true;\n }\n }\n\n modules.length = count;\n\n return modules;\n }\n}\n"],"file":"pipeline-factory.js"}
|