@luma.gl/engine 9.0.0-alpha.5 → 9.0.0-alpha.51
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/LICENSE +3 -1
- 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 +6 -27
- package/dist/animation/key-frames.js.map +1 -1
- package/dist/animation/timeline.d.ts +9 -9
- package/dist/animation/timeline.d.ts.map +1 -1
- package/dist/animation/timeline.js +18 -49
- package/dist/animation/timeline.js.map +1 -1
- package/dist/{lib → animation-loop}/animation-loop.d.ts +30 -31
- package/dist/animation-loop/animation-loop.d.ts.map +1 -0
- package/dist/{lib → animation-loop}/animation-loop.js +115 -199
- package/dist/animation-loop/animation-loop.js.map +1 -0
- package/dist/{lib → animation-loop}/animation-props.d.ts +6 -7
- package/dist/animation-loop/animation-props.d.ts.map +1 -0
- package/dist/animation-loop/animation-props.js.map +1 -0
- package/dist/animation-loop/make-animation-loop.d.ts +6 -0
- package/dist/animation-loop/make-animation-loop.d.ts.map +1 -0
- package/dist/animation-loop/make-animation-loop.js +28 -0
- package/dist/animation-loop/make-animation-loop.js.map +1 -0
- package/dist/animation-loop/render-loop.d.ts +23 -0
- package/dist/animation-loop/render-loop.d.ts.map +1 -0
- package/dist/animation-loop/render-loop.js +7 -0
- package/dist/animation-loop/render-loop.js.map +1 -0
- package/dist/dist.dev.js +7064 -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 +6 -5
- package/dist/geometries/cone-geometry.js.map +1 -1
- package/dist/geometries/cube-geometry.d.ts +2 -2
- package/dist/geometries/cube-geometry.d.ts.map +1 -1
- package/dist/geometries/cube-geometry.js +15 -8
- package/dist/geometries/cube-geometry.js.map +1 -1
- 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 +6 -5
- package/dist/geometries/cylinder-geometry.js.map +1 -1
- package/dist/geometries/ico-sphere-geometry.d.ts +2 -2
- package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
- package/dist/geometries/ico-sphere-geometry.js +10 -19
- package/dist/geometries/ico-sphere-geometry.js.map +1 -1
- package/dist/geometries/plane-geometry.d.ts +2 -2
- package/dist/geometries/plane-geometry.d.ts.map +1 -1
- package/dist/geometries/plane-geometry.js +14 -23
- package/dist/geometries/plane-geometry.js.map +1 -1
- package/dist/geometries/sphere-geometry.d.ts +2 -2
- package/dist/geometries/sphere-geometry.d.ts.map +1 -1
- package/dist/geometries/sphere-geometry.js +9 -13
- package/dist/geometries/sphere-geometry.js.map +1 -1
- package/dist/geometries/truncated-cone-geometry.d.ts +2 -4
- package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
- package/dist/geometries/truncated-cone-geometry.js +9 -25
- package/dist/geometries/truncated-cone-geometry.js.map +1 -1
- package/dist/geometry/geometry-table.d.ts +2 -2
- package/dist/geometry/geometry-table.d.ts.map +1 -1
- package/dist/geometry/geometry-table.js.map +1 -1
- package/dist/geometry/geometry-utils.d.ts.map +1 -1
- package/dist/geometry/geometry-utils.js +0 -9
- package/dist/geometry/geometry-utils.js.map +1 -1
- package/dist/geometry/geometry.d.ts +50 -59
- package/dist/geometry/geometry.d.ts.map +1 -1
- package/dist/geometry/geometry.js +32 -97
- package/dist/geometry/geometry.js.map +1 -1
- package/dist/geometry/gpu-geometry.d.ts +37 -0
- package/dist/geometry/gpu-geometry.d.ts.map +1 -0
- package/dist/geometry/gpu-geometry.js +107 -0
- package/dist/geometry/gpu-geometry.js.map +1 -0
- package/dist/geometry/gpu-table.d.ts +1 -0
- package/dist/geometry/gpu-table.d.ts.map +1 -0
- package/dist/geometry/gpu-table.js +2 -0
- package/dist/geometry/gpu-table.js.map +1 -0
- package/dist/index.cjs +2959 -0
- package/dist/index.d.ts +26 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -13
- package/dist/index.js.map +1 -1
- package/dist/lib/clip-space.d.ts +8 -0
- package/dist/lib/clip-space.d.ts.map +1 -1
- package/dist/lib/clip-space.js +47 -0
- package/dist/lib/clip-space.js.map +1 -1
- package/dist/lib/pipeline-factory.d.ts +12 -40
- package/dist/lib/pipeline-factory.d.ts.map +1 -1
- package/dist/lib/pipeline-factory.js +50 -148
- package/dist/lib/pipeline-factory.js.map +1 -1
- package/dist/model/model.d.ts +192 -0
- package/dist/model/model.d.ts.map +1 -0
- package/dist/model/model.js +312 -0
- package/dist/model/model.js.map +1 -0
- package/dist/scenegraph/group-node.d.ts +21 -0
- package/dist/scenegraph/group-node.d.ts.map +1 -0
- package/dist/scenegraph/group-node.js +94 -0
- package/dist/scenegraph/group-node.js.map +1 -0
- package/dist/scenegraph/model-node.d.ts +18 -0
- package/dist/scenegraph/model-node.d.ts.map +1 -0
- package/dist/scenegraph/model-node.js +28 -0
- package/dist/scenegraph/model-node.js.map +1 -0
- package/dist/scenegraph/scenegraph-node.d.ts +56 -0
- package/dist/scenegraph/scenegraph-node.d.ts.map +1 -0
- package/dist/scenegraph/scenegraph-node.js +141 -0
- package/dist/scenegraph/scenegraph-node.js.map +1 -0
- package/dist/shader-inputs.d.ts +62 -0
- package/dist/shader-inputs.d.ts.map +1 -0
- package/dist/shader-inputs.js +49 -0
- package/dist/shader-inputs.js.map +1 -0
- package/dist/transform/buffer-transform.d.ts +35 -0
- package/dist/transform/buffer-transform.d.ts.map +1 -0
- package/dist/transform/buffer-transform.js +62 -0
- package/dist/transform/buffer-transform.js.map +1 -0
- package/dist/transform/texture-transform.d.ts +57 -0
- package/dist/transform/texture-transform.d.ts.map +1 -0
- package/dist/transform/texture-transform.js +122 -0
- package/dist/transform/texture-transform.js.map +1 -0
- package/dist.min.js +286 -0
- package/package.json +21 -12
- package/src/animation/timeline.ts +16 -15
- package/src/{lib → animation-loop}/animation-loop.ts +120 -107
- package/src/{lib → animation-loop}/animation-props.ts +5 -5
- package/src/animation-loop/make-animation-loop.ts +44 -0
- package/src/animation-loop/render-loop.ts +23 -0
- package/src/geometries/cone-geometry.ts +1 -1
- package/src/geometries/cube-geometry.ts +6 -3
- package/src/geometries/cylinder-geometry.ts +2 -2
- package/src/geometries/ico-sphere-geometry.ts +7 -6
- package/src/geometries/plane-geometry.ts +5 -4
- package/src/geometries/sphere-geometry.ts +4 -3
- package/src/geometries/truncated-cone-geometry.ts +4 -13
- package/src/geometry/geometry-table.ts +1 -1
- package/src/geometry/geometry-utils.ts +3 -3
- package/src/geometry/geometry.ts +79 -119
- package/src/geometry/gpu-geometry.ts +124 -0
- package/src/geometry/gpu-table.ts +41 -0
- package/src/index.ts +38 -12
- package/src/lib/clip-space.ts +22 -21
- package/src/lib/pipeline-factory.ts +60 -168
- package/src/model/model.ts +549 -0
- package/src/scenegraph/group-node.ts +103 -0
- package/src/scenegraph/model-node.ts +50 -0
- package/src/scenegraph/scenegraph-node.ts +204 -0
- package/src/shader-inputs.ts +132 -0
- package/src/transform/buffer-transform.ts +94 -0
- package/src/transform/texture-transform.ts +169 -0
- package/dist/bundle.d.ts +0 -2
- package/dist/bundle.d.ts.map +0 -1
- package/dist/bundle.js +0 -5
- package/dist/bundle.js.map +0 -1
- package/dist/geometry/primitive-utils.d.ts +0 -1
- package/dist/geometry/primitive-utils.d.ts.map +0 -1
- package/dist/geometry/primitive-utils.js +0 -2
- package/dist/geometry/primitive-utils.js.map +0 -1
- package/dist/lib/animation-loop.d.ts.map +0 -1
- package/dist/lib/animation-loop.js.map +0 -1
- package/dist/lib/animation-props.d.ts.map +0 -1
- package/dist/lib/animation-props.js.map +0 -1
- package/dist/lib/model-utils.d.ts +0 -5
- package/dist/lib/model-utils.d.ts.map +0 -1
- package/dist/lib/model-utils.js +0 -45
- package/dist/lib/model-utils.js.map +0 -1
- package/dist/lib/model.d.ts +0 -41
- package/dist/lib/model.d.ts.map +0 -1
- package/dist/lib/model.js +0 -176
- package/dist/lib/model.js.map +0 -1
- package/dist/lib/render-loop.d.ts +0 -14
- package/dist/lib/render-loop.d.ts.map +0 -1
- package/dist/lib/render-loop.js +0 -49
- package/dist/lib/render-loop.js.map +0 -1
- package/src/bundle.ts +0 -4
- package/src/geometry/primitive-utils.ts +0 -30
- package/src/lib/model-utils.ts +0 -124
- package/src/lib/model.ts +0 -179
- package/src/lib/render-loop.ts +0 -58
- /package/dist/{lib → animation-loop}/animation-props.js +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/animation-loop.ts"],"names":["luma","requestAnimationFrame","cancelAnimationFrame","isBrowser","isPage","document","statIdCounter","DEFAULT_ANIMATION_LOOP_PROPS","onCreateDevice","props","createDevice","onAddHTML","undefined","onInitialize","onRender","onFinalize","onError","error","console","device","deviceProps","debug","stats","get","useDevicePixels","autoResizeViewport","autoResizeDrawingBuffer","AnimationLoop","constructor","gl","cpuTime","gpuTime","frameRate","setProps","start","bind","stop","_onMousemove","_onMouseleave","destroy","_setDisplay","delete","setNeedsRedraw","reason","needsRedraw","_running","appContext","_initialized","_createDevice","_initialize","animationProps","_cancelAnimationFrame","_requestAnimationFrame","err","Error","redraw","isLost","_beginTimers","_setupFrame","_updateCallbackData","_renderFrame","_clearNeedsRedraw","_resolveNextFrame","_nextFramePromise","_endTimers","attachTimeline","timeline","detachTimeline","waitForRender","Promise","resolve","toDataURL","canvas","_startEventHandling","_initializeCallbackData","_resizeCanvasDrawingBuffer","_resizeViewport","display","animationLoop","_animationFrameId","_animationFrame","canvasContext","width","height","aspect","time","startTime","Date","now","engineTime","tick","tock","_mousePosition","_getSizeAndAspect","update","Math","floor","getTime","_createInfoDiv","wrapperDiv","createElement","body","appendChild","style","position","div","left","bottom","background","html","innerHTML","getPixelSize","clientHeight","clientWidth","viewport","drawingBufferWidth","drawingBufferHeight","resize","timeEnd","timeStart","addEventListener","e","offsetX","offsetY"],"mappings":";AAAA,SAAQA,IAAR,QAAwC,cAAxC;AACA,S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YAAY,CAACoF,CAAD,EAAI;AACd,SAAKvE,cAAL,CAAoB0C,cAApB,GAAqC,CAAC6B,CAAC,CAACC,OAAH,EAAYD,CAAC,CAACE,OAAd,CAArC;AACD;;AACDrF,EAAAA,aAAa,CAACmF,CAAD,EAAI;AACf,SAAKvE,cAAL,CAAoB0C,cAApB,GAAqC,IAArC;AACD;;AAhegC","sourcesContent":["import {luma, Device, DeviceProps} from '@luma.gl/api';\nimport {requestAnimationFrame, cancelAnimationFrame} from '@luma.gl/api';\nimport {Timeline} from '../animation/timeline';\nimport {AnimationProps} from '../lib/animation-props';\nimport {Stats, Stat} from '@probe.gl/stats';\nimport {isBrowser} from '@probe.gl/env';\n\nconst isPage = isBrowser() && typeof document !== 'undefined';\n\nlet statIdCounter = 0;\n\ntype ContextProps = DeviceProps;\n\n/** AnimationLoop properties */\nexport type AnimationLoopProps = {\n onCreateDevice?: (props: DeviceProps) => Promise<Device>;\n onAddHTML?: (div: HTMLDivElement) => string; // innerHTML\n onInitialize?: (animationProps: AnimationProps) => void;\n onRender?: (animationProps: AnimationProps) => void;\n onFinalize?: (animationProps: AnimationProps) => void;\n onError?: (reason: Error) => void;\n\n device?: Device;\n deviceProps?: DeviceProps;\n stats?: Stats;\n\n // view parameters\n debug?: boolean;\n autoResizeViewport?: boolean;\n autoResizeDrawingBuffer?: boolean;\n useDevicePixels?: number | boolean;\n};\n\nconst DEFAULT_ANIMATION_LOOP_PROPS: Required<AnimationLoopProps> = {\n onCreateDevice: (props: DeviceProps): Promise<Device> => luma.createDevice(props),\n onAddHTML: undefined,\n onInitialize: () => ({}),\n onRender: () => {},\n onFinalize: () => {},\n onError: (error) => console.error(error), // eslint-disable-line no-console\n\n device: undefined,\n deviceProps: {},\n debug: false,\n stats: luma.stats.get(`animation-loop-${statIdCounter++}`),\n\n // view parameters\n useDevicePixels: true,\n autoResizeViewport: true,\n autoResizeDrawingBuffer: true,\n};\n\n/** Convenient animation loop */\nexport default class AnimationLoop {\n device: Device;\n canvas: HTMLCanvasElement; // | OffscreenCanvas;\n\n props: Required<AnimationLoopProps>;\n animationProps: AnimationProps;\n timeline: Timeline = null;\n stats: Stats;\n cpuTime: Stat;\n gpuTime: Stat;\n frameRate: Stat;\n\n display: any;\n\n needsRedraw: string | null = 'initialized';\n\n _initialized: boolean = false;\n _running: boolean = false;\n _animationFrameId = null;\n _nextFramePromise: Promise<AnimationLoop> | null = null;\n _resolveNextFrame: ((AnimationLoop) => void) | null = null;\n _cpuStartTime: number = 0;\n\n // _gpuTimeQuery: Query | null = null;\n\n /*\n * @param {HTMLCanvasElement} canvas - if provided, width and height will be passed to context\n */\n constructor(props: AnimationLoopProps = {}) {\n this.props = {...DEFAULT_ANIMATION_LOOP_PROPS, ...props};\n props = this.props;\n\n let {useDevicePixels = true} = this.props;\n\n // state\n this.device = props.device;\n // @ts-expect-error\n this.gl = (this.device && this.device.gl) || props.gl;\n\n this.stats = props.stats;\n this.cpuTime = this.stats.get('CPU Time');\n this.gpuTime = this.stats.get('GPU Time');\n this.frameRate = this.stats.get('Frame Rate');\n\n this.setProps({\n autoResizeViewport: props.autoResizeViewport,\n autoResizeDrawingBuffer: props.autoResizeDrawingBuffer,\n useDevicePixels\n });\n\n // Bind methods\n this.start = this.start.bind(this);\n this.stop = this.stop.bind(this);\n\n this._onMousemove = this._onMousemove.bind(this);\n this._onMouseleave = this._onMouseleave.bind(this);\n }\n\n destroy(): void {\n this.stop();\n this._setDisplay(null);\n }\n\n /** @deprecated Use .destroy() */\n delete(): void {\n this.destroy();\n }\n\n setNeedsRedraw(reason: string): this {\n this.needsRedraw = this.needsRedraw || reason;\n return this;\n }\n\n // TODO - move to CanvasContext\n setProps(props: AnimationLoopProps): this {\n if ('autoResizeViewport' in props) {\n this.props.autoResizeViewport = props.autoResizeViewport;\n }\n if ('autoResizeDrawingBuffer' in props) {\n this.props.autoResizeDrawingBuffer = props.autoResizeDrawingBuffer;\n }\n if ('useDevicePixels' in props) {\n this.props.useDevicePixels = props.useDevicePixels;\n }\n return this;\n }\n\n /** Starts a render loop if not already running */\n async start() {\n if (this._running) {\n return this;\n }\n this._running = true;\n\n try {\n // check that we haven't been stopped\n if (!this._running) {\n return null;\n }\n\n let appContext;\n if (!this._initialized) {\n this._initialized = true;\n // Create the WebGL context\n await this._createDevice();\n this._initialize();\n\n // Note: onIntialize can return a promise (e.g. in case app needs to load resources)\n await this.onInitialize(this.animationProps);\n }\n\n // check that we haven't been stopped\n if (!this._running) {\n return null;\n }\n\n // Start the loop\n if (appContext !== false) {\n // cancel any pending renders to ensure only one loop can ever run\n this._cancelAnimationFrame();\n this._requestAnimationFrame();\n }\n\n return this;\n } catch (err: unknown) {\n const error = err instanceof Error ? err : new Error('Unknown error')\n this.props.onError(error);\n // this._running = false; // TODO\n throw error;\n }\n }\n\n /** Explicitly draw a frame */\n redraw(): this {\n if (this.device.isLost) {\n return this;\n }\n\n this._beginTimers();\n\n this._setupFrame();\n this._updateCallbackData();\n\n this._renderFrame(this.animationProps);\n\n // clear needsRedraw flag\n this._clearNeedsRedraw();\n\n if (this._resolveNextFrame) {\n this._resolveNextFrame(this);\n this._nextFramePromise = null;\n this._resolveNextFrame = null;\n }\n\n this._endTimers();\n\n return this;\n }\n\n // Stops a render loop if already running, finalizing\n stop() {\n // console.debug(`Stopping ${this.constructor.name}`);\n if (this._running) {\n // call callback\n this.onFinalize(this.animationProps);\n\n this._cancelAnimationFrame();\n this._nextFramePromise = null;\n this._resolveNextFrame = null;\n this._running = false;\n }\n return this;\n }\n\n attachTimeline(timeline: Timeline): Timeline {\n this.timeline = timeline;\n return this.timeline;\n }\n\n detachTimeline(): void {\n this.timeline = null;\n }\n\n waitForRender(): Promise<AnimationLoop> {\n this.setNeedsRedraw('waitForRender');\n\n if (!this._nextFramePromise) {\n this._nextFramePromise = new Promise((resolve) => {\n this._resolveNextFrame = resolve;\n });\n }\n return this._nextFramePromise;\n }\n\n async toDataURL() {\n this.setNeedsRedraw('toDataURL');\n await this.waitForRender();\n return this.canvas.toDataURL();\n }\n\n onCreateDevice(deviceProps: DeviceProps): Promise<Device> {\n return this.props.onCreateDevice(deviceProps);\n }\n\n onInitialize(animationProps: AnimationProps): {} | void {\n return this.props.onInitialize(animationProps);\n }\n\n onRender(animationProps: AnimationProps) {\n return this.props.onRender(animationProps);\n }\n\n onFinalize(animationProps: AnimationProps) {\n return this.props.onFinalize(animationProps);\n }\n\n // PRIVATE METHODS\n\n _initialize() {\n this._startEventHandling();\n\n // Initialize the callback data\n this._initializeCallbackData();\n this._updateCallbackData();\n\n // Default viewport setup, in case onInitialize wants to render\n this._resizeCanvasDrawingBuffer();\n this._resizeViewport();\n\n // this._gpuTimeQuery = Query.isSupported(this.gl, ['timers']) ? new Query(this.gl) : null;\n }\n\n _setDisplay(display) {\n if (this.display) {\n this.display.delete();\n this.display.animationLoop = null;\n }\n\n // store animation loop on the display\n if (display) {\n display.animationLoop = this;\n }\n\n this.display = display;\n }\n\n _requestAnimationFrame() {\n if (!this._running) {\n return;\n }\n\n // VR display has a separate animation frame to sync with headset\n // TODO WebVR API discontinued, replaced by WebXR: https://immersive-web.github.io/webxr/\n // See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/requestAnimationFrame\n // if (this.display && this.display.requestAnimationFrame) {\n // this._animationFrameId = this.display.requestAnimationFrame(this._animationFrame.bind(this));\n // }\n this._animationFrameId = requestAnimationFrame(this._animationFrame.bind(this));\n }\n\n _cancelAnimationFrame() {\n if (this._animationFrameId !== null) {\n return;\n }\n\n // VR display has a separate animation frame to sync with headset\n // TODO WebVR API discontinued, replaced by WebXR: https://immersive-web.github.io/webxr/\n // See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/requestAnimationFrame\n // if (this.display && this.display.cancelAnimationFrame) {\n // this.display.cancelAnimationFrame(this._animationFrameId);\n // }\n cancelAnimationFrame(this._animationFrameId);\n this._animationFrameId = null;\n }\n\n _animationFrame() {\n if (!this._running) {\n return;\n }\n this.redraw();\n this._requestAnimationFrame();\n }\n\n // Called on each frame, can be overridden to call onRender multiple times\n // to support e.g. stereoscopic rendering\n _renderFrame(props: AnimationProps) {\n // Allow e.g. VR display to render multiple frames.\n if (this.display) {\n this.display._renderFrame(props);\n return;\n }\n\n // call callback\n this.onRender(props);\n // end callback\n }\n\n _clearNeedsRedraw() {\n this.needsRedraw = null;\n }\n\n _setupFrame() {\n this._resizeCanvasDrawingBuffer();\n this._resizeViewport();\n }\n\n // Initialize the object that will be passed to app callbacks\n _initializeCallbackData() {\n this.animationProps = {\n animationLoop: this,\n device: this.device,\n canvas: this.device.canvasContext.canvas,\n timeline: this.timeline,\n\n // Initial values\n useDevicePixels: this.props.useDevicePixels,\n needsRedraw: null,\n\n // Placeholders\n width: 1,\n height: 1,\n aspect: 1,\n\n // Animation props\n time: 0,\n startTime: Date.now(),\n engineTime: 0,\n tick: 0,\n tock: 0,\n\n // Experimental\n _mousePosition: null // Event props\n };\n }\n\n // Update the context object that will be passed to app callbacks\n _updateCallbackData() {\n const {width, height, aspect} = this._getSizeAndAspect();\n if (width !== this.animationProps.width || height !== this.animationProps.height) {\n this.setNeedsRedraw('drawing buffer resized');\n }\n if (aspect !== this.animationProps.aspect) {\n this.setNeedsRedraw('drawing buffer aspect changed');\n }\n\n this.animationProps.width = width;\n this.animationProps.height = height;\n this.animationProps.aspect = aspect;\n\n this.animationProps.needsRedraw = this.needsRedraw;\n\n // Update time properties\n this.animationProps.engineTime = Date.now() - this.animationProps.startTime;\n\n if (this.timeline) {\n this.timeline.update(this.animationProps.engineTime);\n }\n\n this.animationProps.tick = Math.floor((this.animationProps.time / 1000) * 60);\n this.animationProps.tock++;\n\n // For back compatibility\n this.animationProps.time = this.timeline\n ? this.timeline.getTime()\n : this.animationProps.engineTime;\n }\n\n /** Either uses supplied or existing context, or calls provided callback to create one */\n async _createDevice() {\n const deviceProps = {...this.props, ...this.props.deviceProps};\n this.device = await this.onCreateDevice(deviceProps);\n // @ts-expect-error\n this.canvas = this.device.canvasContext.canvas;\n this._createInfoDiv();\n }\n\n _createInfoDiv() {\n if (this.canvas && this.props.onAddHTML) {\n const wrapperDiv = document.createElement('div');\n document.body.appendChild(wrapperDiv);\n wrapperDiv.style.position = 'relative';\n const div = document.createElement('div');\n div.style.position = 'absolute';\n div.style.left = '10px';\n div.style.bottom = '10px';\n div.style.width = '300px';\n div.style.background = 'white';\n wrapperDiv.appendChild(this.canvas);\n wrapperDiv.appendChild(div);\n const html = this.props.onAddHTML(div);\n if (html) {\n div.innerHTML = html;\n }\n }\n }\n\n _getSizeAndAspect() {\n // https://webglfundamentals.org/webgl/lessons/webgl-resizing-the-canvas.html\n const [width, height] = this.device.canvasContext.getPixelSize();\n\n // https://webglfundamentals.org/webgl/lessons/webgl-anti-patterns.html\n let aspect = 1;\n const canvas = this.device.canvasContext.canvas;\n\n // @ts-expect-error\n if (canvas && canvas.clientHeight) {\n // @ts-expect-error\n aspect = canvas.clientWidth / canvas.clientHeight;\n } else if (width > 0 && height > 0) {\n aspect = width / height;\n }\n\n return {width, height, aspect};\n }\n\n /** Default viewport setup */\n _resizeViewport() {\n // @ts-expect-error Expose on canvasContext\n if (this.props.autoResizeViewport && this.device.gl) {\n // @ts-expect-error Expose canvasContext\n this.device.gl.viewport(0, 0, this.device.gl.drawingBufferWidth, this.device.gl.drawingBufferHeight);\n }\n }\n\n /**\n * Resize the render buffer of the canvas to match canvas client size\n * Optionally multiplying with devicePixel ratio\n */\n _resizeCanvasDrawingBuffer() {\n if (this.props.autoResizeDrawingBuffer) {\n this.device.canvasContext.resize({useDevicePixels: this.props.useDevicePixels});\n }\n }\n\n _beginTimers() {\n this.frameRate.timeEnd();\n this.frameRate.timeStart();\n\n // Check if timer for last frame has completed.\n // GPU timer results are never available in the same\n // frame they are captured.\n // if (\n // this._gpuTimeQuery &&\n // this._gpuTimeQuery.isResultAvailable() &&\n // !this._gpuTimeQuery.isTimerDisjoint()\n // ) {\n // this.stats.get('GPU Time').addTime(this._gpuTimeQuery.getTimerMilliseconds());\n // }\n\n // if (this._gpuTimeQuery) {\n // // GPU time query start\n // this._gpuTimeQuery.beginTimeElapsedQuery();\n // }\n\n // this.cpuTime.timeStart();\n }\n\n _endTimers() {\n this.cpuTime.timeEnd();\n\n // if (this._gpuTimeQuery) {\n // // GPU time query end. Results will be available on next frame.\n // this._gpuTimeQuery.end();\n // }\n }\n\n // Event handling\n\n _startEventHandling() {\n if (this.canvas) {\n this.canvas.addEventListener('mousemove', this._onMousemove);\n this.canvas.addEventListener('mouseleave', this._onMouseleave);\n }\n }\n\n _onMousemove(e) {\n this.animationProps._mousePosition = [e.offsetX, e.offsetY];\n }\n _onMouseleave(e) {\n this.animationProps._mousePosition = null;\n }\n}\n"],"file":"animation-loop.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"animation-props.d.ts","sourceRoot":"","sources":["../../src/lib/animation-props.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AACpC,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAC9C,OAAO,KAAK,aAAa,MAAM,kBAAkB,CAAC;AAElD,+CAA+C;AAC/C,oBAAY,cAAc,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,aAAa,CAAC;IAE7B,oCAAoC;IACpC,MAAM,EAAE,iBAAiB,GAAG,eAAe,CAAC;IAC5C,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IAGf,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IAGb,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,QAAQ,EAAE,QAAQ,CAAC;IAGnB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"animation-props.js"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { Device, Buffer } from '@luma.gl/api';
|
|
2
|
-
import type Geometry from '../geometry/geometry';
|
|
3
|
-
export declare function getIndexBufferFromGeometry(device: Device, geometry: Geometry): Buffer | undefined;
|
|
4
|
-
export declare function getAttributeBuffersFromGeometry(device: Device, geometry: Geometry): Record<string, Buffer>;
|
|
5
|
-
//# sourceMappingURL=model-utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"model-utils.d.ts","sourceRoot":"","sources":["../../src/lib/model-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAE,MAAM,EAAS,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AAsDjD,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,CAYjG;AAED,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAc1G"}
|
package/dist/lib/model-utils.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { Buffer, assert } from '@luma.gl/api';
|
|
2
|
-
const GLTF_TO_LUMA_ATTRIBUTE_MAP = {
|
|
3
|
-
POSITION: 'positions',
|
|
4
|
-
NORMAL: 'normals',
|
|
5
|
-
COLOR_0: 'colors',
|
|
6
|
-
TEXCOORD_0: 'texCoords',
|
|
7
|
-
TEXCOORD_1: 'texCoords1',
|
|
8
|
-
TEXCOORD_2: 'texCoords2'
|
|
9
|
-
};
|
|
10
|
-
export function getIndexBufferFromGeometry(device, geometry) {
|
|
11
|
-
if (!geometry.indices) {
|
|
12
|
-
return undefined;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const data = geometry.indices.value || geometry.indices;
|
|
16
|
-
assert(data instanceof Uint16Array || data instanceof Uint32Array, 'attribute array for "indices" must be of integer type');
|
|
17
|
-
return device.createBuffer({
|
|
18
|
-
usage: Buffer.INDEX,
|
|
19
|
-
data
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
export function getAttributeBuffersFromGeometry(device, geometry) {
|
|
23
|
-
const buffers = {};
|
|
24
|
-
|
|
25
|
-
for (const [name, attribute] of Object.entries(geometry.attributes)) {
|
|
26
|
-
const remappedName = mapAttributeName(name);
|
|
27
|
-
|
|
28
|
-
if (attribute.constant) {
|
|
29
|
-
throw new Error('constant attributes not supported');
|
|
30
|
-
} else {
|
|
31
|
-
const typedArray = attribute.value;
|
|
32
|
-
buffers[remappedName] = device.createBuffer({
|
|
33
|
-
data: typedArray,
|
|
34
|
-
id: "".concat(remappedName, "-buffer")
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return buffers;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function mapAttributeName(name) {
|
|
43
|
-
return GLTF_TO_LUMA_ATTRIBUTE_MAP[name] || name;
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=model-utils.js.map
|
|
@@ -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;AAI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L,YAAL;AAArB,OAApB,CAAxB;AACD;AACF;;AAED,SAAON,OAAP;AACD;;AAED,SAASO,gBAAT,CAA0BN,IAA1B,EAAgD;AAC9C,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 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.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { Device, Buffer, RenderPipelineProps, RenderPass, Binding } from '@luma.gl/api';
|
|
2
|
-
import { RenderPipeline } from '@luma.gl/api';
|
|
3
|
-
import type { ShaderModule } from '@luma.gl/shadertools';
|
|
4
|
-
import type Geometry from '../geometry/geometry';
|
|
5
|
-
export declare type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {
|
|
6
|
-
vs?: {
|
|
7
|
-
glsl?: string;
|
|
8
|
-
wgsl?: string;
|
|
9
|
-
} | string;
|
|
10
|
-
fs?: {
|
|
11
|
-
glsl?: string;
|
|
12
|
-
wgsl?: string;
|
|
13
|
-
} | string;
|
|
14
|
-
modules?: ShaderModule[];
|
|
15
|
-
moduleSettings?: Record<string, Record<string, any>>;
|
|
16
|
-
geometry?: Geometry;
|
|
17
|
-
};
|
|
18
|
-
/** v9 API */
|
|
19
|
-
export default class Model {
|
|
20
|
-
readonly device: Device;
|
|
21
|
-
readonly pipeline: RenderPipeline;
|
|
22
|
-
readonly id: string;
|
|
23
|
-
readonly vs: string;
|
|
24
|
-
readonly fs: string | undefined;
|
|
25
|
-
readonly topology: string;
|
|
26
|
-
readonly vertexCount: any;
|
|
27
|
-
props: Required<ModelProps>;
|
|
28
|
-
private _getModuleUniforms;
|
|
29
|
-
constructor(device: Device, props: ModelProps);
|
|
30
|
-
destroy(): void;
|
|
31
|
-
draw(renderPass?: RenderPass): this;
|
|
32
|
-
setProps(props: ModelProps): this;
|
|
33
|
-
updateModuleSettings(props: Record<string, any>): this;
|
|
34
|
-
setIndexBuffer(indices: Buffer): this;
|
|
35
|
-
setAttributes(attributes: Record<string, Buffer>): this;
|
|
36
|
-
/** Set the bindings */
|
|
37
|
-
setBindings(bindings: Record<string, Binding>): this;
|
|
38
|
-
setUniforms(uniforms: Record<string, any>): this;
|
|
39
|
-
_setGeometry(geometry: Geometry): void;
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=model.d.ts.map
|
package/dist/lib/model.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/lib/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAE,MAAM,EAAE,mBAAmB,EAAE,UAAU,EAAE,OAAO,EAAC,MAAM,cAAc,CAAC;AAC3F,OAAO,EAAC,cAAc,EAAe,MAAM,cAAc,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AAIjD,oBAAY,UAAU,GAAG,IAAI,CAAC,mBAAmB,EAAE,IAAI,GAAG,IAAI,CAAC,GAAG;IAEhE,EAAE,CAAC,EAAE;QA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I;IAMvD,uBAAuB;IACvB,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAMpD,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IAMhD,YAAY,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;CAWvC"}
|
package/dist/lib/model.js
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import { RenderPipeline } from '@luma.gl/api';
|
|
3
|
-
import { getAttributeBuffersFromGeometry, getIndexBufferFromGeometry } from './model-utils';
|
|
4
|
-
import PipelineFactory from './pipeline-factory';
|
|
5
|
-
const DEFAULT_MODEL_PROPS = { ...RenderPipeline._DEFAULT_PROPS,
|
|
6
|
-
vs: undefined,
|
|
7
|
-
fs: undefined,
|
|
8
|
-
id: 'unnamed',
|
|
9
|
-
handle: undefined,
|
|
10
|
-
userData: {},
|
|
11
|
-
modules: [],
|
|
12
|
-
moduleSettings: {},
|
|
13
|
-
geometry: undefined
|
|
14
|
-
};
|
|
15
|
-
export default class Model {
|
|
16
|
-
constructor(device, props) {
|
|
17
|
-
_defineProperty(this, "device", void 0);
|
|
18
|
-
|
|
19
|
-
_defineProperty(this, "pipeline", void 0);
|
|
20
|
-
|
|
21
|
-
_defineProperty(this, "id", void 0);
|
|
22
|
-
|
|
23
|
-
_defineProperty(this, "vs", void 0);
|
|
24
|
-
|
|
25
|
-
_defineProperty(this, "fs", void 0);
|
|
26
|
-
|
|
27
|
-
_defineProperty(this, "topology", void 0);
|
|
28
|
-
|
|
29
|
-
_defineProperty(this, "vertexCount", void 0);
|
|
30
|
-
|
|
31
|
-
_defineProperty(this, "props", void 0);
|
|
32
|
-
|
|
33
|
-
_defineProperty(this, "_getModuleUniforms", void 0);
|
|
34
|
-
|
|
35
|
-
this.props = { ...DEFAULT_MODEL_PROPS,
|
|
36
|
-
...props
|
|
37
|
-
};
|
|
38
|
-
props = this.props;
|
|
39
|
-
this.id = props.id;
|
|
40
|
-
this.device = device;
|
|
41
|
-
this.vs = getShaderSource(this.device, props.vs);
|
|
42
|
-
|
|
43
|
-
if (props.fs) {
|
|
44
|
-
this.fs = getShaderSource(this.device, props.fs);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
this.vertexCount = this.props.vertexCount;
|
|
48
|
-
this.topology = this.props.topology;
|
|
49
|
-
|
|
50
|
-
if (this.props.geometry) {
|
|
51
|
-
this.vertexCount = this.props.geometry.vertexCount;
|
|
52
|
-
this.topology = this.props.geometry.topology;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const {
|
|
56
|
-
renderPipeline,
|
|
57
|
-
getUniforms
|
|
58
|
-
} = PipelineFactory.getDefaultPipelineFactory(this.device).createRenderPipeline({ ...this.props,
|
|
59
|
-
vs: this.vs,
|
|
60
|
-
fs: this.fs,
|
|
61
|
-
topology: this.topology,
|
|
62
|
-
parameters: props.parameters,
|
|
63
|
-
layout: props.layout
|
|
64
|
-
});
|
|
65
|
-
this.pipeline = renderPipeline;
|
|
66
|
-
this._getModuleUniforms = getUniforms;
|
|
67
|
-
|
|
68
|
-
if (this.props.geometry) {
|
|
69
|
-
this._setGeometry(this.props.geometry);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
this.setUniforms(this._getModuleUniforms());
|
|
73
|
-
this.setProps(this.props);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
destroy() {
|
|
77
|
-
this.pipeline.destroy();
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
draw(renderPass) {
|
|
81
|
-
this.pipeline.draw({
|
|
82
|
-
renderPass,
|
|
83
|
-
vertexCount: this.vertexCount,
|
|
84
|
-
instanceCount: this.props.instanceCount
|
|
85
|
-
});
|
|
86
|
-
return this;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
setProps(props) {
|
|
90
|
-
if (props.indices) {
|
|
91
|
-
this.setIndexBuffer(props.indices);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (props.attributes) {
|
|
95
|
-
this.setAttributes(props.attributes);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (props.bindings) {
|
|
99
|
-
this.setBindings(props.bindings);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if (props.uniforms) {
|
|
103
|
-
this.setUniforms(props.uniforms);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (props.moduleSettings) {
|
|
107
|
-
this.updateModuleSettings(props.moduleSettings);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return this;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
updateModuleSettings(props) {
|
|
114
|
-
const uniforms = this._getModuleUniforms(props);
|
|
115
|
-
|
|
116
|
-
this.setUniforms(uniforms);
|
|
117
|
-
return this;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
setIndexBuffer(indices) {
|
|
121
|
-
this.pipeline.setIndexBuffer(indices);
|
|
122
|
-
return this;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
setAttributes(attributes) {
|
|
126
|
-
this.pipeline.setAttributes(attributes);
|
|
127
|
-
Object.assign(this.props.attributes, attributes);
|
|
128
|
-
return this;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
setBindings(bindings) {
|
|
132
|
-
this.pipeline.setBindings(bindings);
|
|
133
|
-
Object.assign(this.props.bindings, bindings);
|
|
134
|
-
return this;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
setUniforms(uniforms) {
|
|
138
|
-
this.pipeline.setUniforms(uniforms);
|
|
139
|
-
Object.assign(this.props.uniforms, uniforms);
|
|
140
|
-
return this;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
_setGeometry(geometry) {
|
|
144
|
-
const geometryBuffers = getAttributeBuffersFromGeometry(this.device, geometry);
|
|
145
|
-
this.setAttributes(geometryBuffers);
|
|
146
|
-
const indexBuffer = getIndexBufferFromGeometry(this.device, geometry);
|
|
147
|
-
|
|
148
|
-
if (indexBuffer) {
|
|
149
|
-
this.setIndexBuffer(indexBuffer);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
function getShaderSource(device, shader) {
|
|
156
|
-
if (typeof shader === 'string') {
|
|
157
|
-
return shader;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
switch (device.info.type) {
|
|
161
|
-
case 'webgpu':
|
|
162
|
-
if (shader !== null && shader !== void 0 && shader.wgsl) {
|
|
163
|
-
return shader.wgsl;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
throw new Error('WebGPU does not support GLSL shaders');
|
|
167
|
-
|
|
168
|
-
default:
|
|
169
|
-
if (shader !== null && shader !== void 0 && shader.glsl) {
|
|
170
|
-
return shader.glsl;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
throw new Error('WebGL does not support WGSL shaders');
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
//# sourceMappingURL=model.js.map
|
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","undefined","fs","id","handle","userData","modules","moduleSettings","geometry","Model","constructor","device","props","getShaderSource","vertexCount","topology","renderPipeline","getUniforms","getDefaultPipelineFactory","createRenderPipeline","parameters","layout","pipeline","_getModuleUniforms","_setGeometry","setUniforms","setProps","destroy","draw","renderPass","instanceCount","indices","setIndexBuffer","attributes","setAttributes","bindings","setBindings","uniforms","updateModuleSettings","Object","assign","geometryBuffers","indexBuffer","shader","info","type","wgsl","Error","glsl"],"mappings":";AACA,SAAQA,cAAR,QAA2C,cAA3C;AAGA,SAAQC,+BAAR,EAAyCC,0BAAz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AAC,KAAKgB,MAAN,EAAcH,QAAd,CAAvD;AACA,SAAK0B,aAAL,CAAmBO,eAAnB;AAEA,UAAMC,WAAW,GAAG9C,0BAA0B,CAAC,KAAKe,MAAN,EAAcH,QAAd,CAA9C;;AACA,QAAIkC,WAAJ,EAAiB;AACf,WAAKV,cAAL,CAAoBU,WAApB;AACD;AACF;;AA9HwB;;AAkI3B,SAAS7B,eAAT,CAAyBF,MAAzB,EAAyCgC,MAAzC,EAAkG;AAEhG,MAAI,OAAOA,MAAP,KAAkB,QAAtB,EAAgC;AAC9B,WAAOA,MAAP;AACD;;AAED,UAAQhC,MAAM,CAACiC,IAAP,CAAYC,IAApB;AACE,SAAK,QAAL;AACE,UAAIF,MAAJ,aAAIA,MAAJ,eAAIA,MAAM,CAAEG,IAAZ,EAAkB;AAChB,eAAOH,MAAM,CAACG,IAAd;AACD;;AACD,YAAM,IAAIC,KAAJ,CAAU,sCAAV,CAAN;;AAEF;AACE,UAAIJ,MAAJ,aAAIA,MAAJ,eAAIA,MAAM,CAAEK,IAAZ,EAAkB;AAChB,eAAOL,MAAM,CAACK,IAAd;AACD;;AACD,YAAM,IAAID,KAAJ,CAAU,qCAAV,CAAN;AAXJ;AAaD","sourcesContent":["import type {Device, Buffer, RenderPipelineProps, RenderPass, Binding} from '@luma.gl/api';\nimport {RenderPipeline, Shader, cast} 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;\n fs?: {glsl?: string; wgsl?: string} | string;\n modules?: ShaderModule[];\n moduleSettings?: Record<string, Record<string, any>>;\n geometry?: Geometry;\n};\n\nconst DEFAULT_MODEL_PROPS: Required<ModelProps> = {\n ...RenderPipeline._DEFAULT_PROPS,\n vs: undefined,\n fs: undefined,\n id: 'unnamed',\n handle: undefined,\n userData: {},\n modules: [],\n moduleSettings: {},\n geometry: undefined\n};\n\n/** v9 API */\nexport default class Model {\n readonly device: Device;\n readonly pipeline: RenderPipeline;\n readonly id: string;\n readonly vs: string;\n readonly fs: string | undefined;\n readonly topology: string;\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 = props.id;\n this.device = device;\n\n // Create the pipeline\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;\n }\n\n const {renderPipeline, getUniforms} = PipelineFactory.getDefaultPipelineFactory(this.device).createRenderPipeline({\n ...this.props,\n vs: this.vs,\n fs: this.fs,\n topology: this.topology,\n parameters: props.parameters,\n // Geometry in the vertex shader!\n // @ts-expect-error\n layout: props.layout\n });\n\n this.pipeline = renderPipeline;\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,14 +0,0 @@
|
|
|
1
|
-
import type { DeviceProps } from '@luma.gl/api';
|
|
2
|
-
import type { AnimationProps } from '../lib/animation-props';
|
|
3
|
-
import AnimationLoop from './animation-loop';
|
|
4
|
-
/**
|
|
5
|
-
* Minimal animation loop that initializes models in constructor
|
|
6
|
-
* Simplifying type management
|
|
7
|
-
* v9 API
|
|
8
|
-
*/
|
|
9
|
-
export declare abstract class RenderLoop {
|
|
10
|
-
constructor(animationProps?: AnimationProps);
|
|
11
|
-
/** Instantiates and runs the render loop */
|
|
12
|
-
static run(RenderLoopConstructor: typeof RenderLoop, deviceProps?: DeviceProps): AnimationLoop;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=render-loop.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"render-loop.d.ts","sourceRoot":"","sources":["../../src/lib/render-loop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,wBAAwB,CAAC;AAC3D,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAE7C;;;;GAIG;AACH,8BAAsB,UAAU;gBAClB,cAAc,CAAC,EAAE,cAAc;IAE3C,4CAA4C;IAC5C,MAAM,CAAC,GAAG,CAAC,qBAAqB,EAAE,OAAO,UAAU,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,aAAa;CAS/F"}
|
package/dist/lib/render-loop.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import AnimationLoop from './animation-loop';
|
|
3
|
-
export class RenderLoop {
|
|
4
|
-
constructor(animationProps) {}
|
|
5
|
-
|
|
6
|
-
static run(RenderLoopConstructor, deviceProps) {
|
|
7
|
-
const animationLoop = new SyncInitAnimationLoop(RenderLoopConstructor, deviceProps);
|
|
8
|
-
return animationLoop;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
class SyncInitAnimationLoop extends AnimationLoop {
|
|
14
|
-
getInfo() {
|
|
15
|
-
return this.RenderLoopConstructor.info;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
constructor(RenderLoopConstructor, deviceProps) {
|
|
19
|
-
super({
|
|
20
|
-
deviceProps
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
_defineProperty(this, "RenderLoopConstructor", void 0);
|
|
24
|
-
|
|
25
|
-
_defineProperty(this, "renderLoop", void 0);
|
|
26
|
-
|
|
27
|
-
this.RenderLoopConstructor = RenderLoopConstructor;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
onInitialize(animationProps) {
|
|
31
|
-
this.renderLoop = new this.RenderLoopConstructor(animationProps);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
onRender(animationProps) {
|
|
35
|
-
var _this$renderLoop, _this$renderLoop$onRe, _this$renderLoop2, _this$renderLoop2$fra;
|
|
36
|
-
|
|
37
|
-
(_this$renderLoop = this.renderLoop) === null || _this$renderLoop === void 0 ? void 0 : (_this$renderLoop$onRe = _this$renderLoop.onRender) === null || _this$renderLoop$onRe === void 0 ? void 0 : _this$renderLoop$onRe.call(_this$renderLoop, animationProps);
|
|
38
|
-
(_this$renderLoop2 = this.renderLoop) === null || _this$renderLoop2 === void 0 ? void 0 : (_this$renderLoop2$fra = _this$renderLoop2.frame) === null || _this$renderLoop2$fra === void 0 ? void 0 : _this$renderLoop2$fra.call(_this$renderLoop2, animationProps);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
onFinalize(animationProps) {
|
|
42
|
-
var _this$renderLoop3, _this$renderLoop3$onF, _this$renderLoop4, _this$renderLoop4$des;
|
|
43
|
-
|
|
44
|
-
(_this$renderLoop3 = this.renderLoop) === null || _this$renderLoop3 === void 0 ? void 0 : (_this$renderLoop3$onF = _this$renderLoop3.onFinalize) === null || _this$renderLoop3$onF === void 0 ? void 0 : _this$renderLoop3$onF.call(_this$renderLoop3, animationProps);
|
|
45
|
-
(_this$renderLoop4 = this.renderLoop) === null || _this$renderLoop4 === void 0 ? void 0 : (_this$renderLoop4$des = _this$renderLoop4.destroy) === null || _this$renderLoop4$des === void 0 ? void 0 : _this$renderLoop4$des.call(_this$renderLoop4, animationProps);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
//# sourceMappingURL=render-loop.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/render-loop.ts"],"names":["AnimationLoop","RenderLoop","constructor","animationProps","run","RenderLoopConstructor","deviceProps","animationLoop","SyncInitAnimationLoop","getInfo","info","onInitialize","renderLoop","onRender","frame","onFinalize","destroy"],"mappings":";AAEA,OAAOA,aAAP,MAA0B,kBAA1B;AAOA,OAAO,MAAeC,UAAf,CAA0B;AAC/BC,EAAAA,WAAW,CAACC,cAAD,EAAkC,CAAE;;AAGrC,SAAHC,GAAG,CAACC,qBAAD,EAA2CC,WAA3C,EAAqF;AAE7F,UAAMC,aAAa,GAAG,IAAIC,qBAAJ,CAA0BH,qBAA1B,EAAiDC,WAAjD,CAAtB;AAKA,WAAOC,aAAP;AACD;;AAZ8B;;AAgBjC,MAAMC,qBAAN,SAAoCR,aAApC,CAAkD;AAIhDS,EAAAA,OAAO,GAAG;AAER,WAAO,KAAKJ,qBAAL,CAA2BK,IAAlC;AACD;;AAEDR,EAAAA,WAAW,CAACG,qBAAD,EAA2CC,WAA3C,EAAsE;AAC/E,UAAM;AAACA,MAAAA;AAAD,KAAN;;AAD+E;;AAAA;;AAE/E,SAAKD,qBAAL,GAA6BA,qBAA7B;AACD;;AAEDM,EAAAA,YAAY,CAACR,cAAD,EAAiC;AAE3C,SAAKS,UAAL,GAAkB,IAAI,KAAKP,qBAAT,CAA+BF,cAA/B,CAAlB;AACD;;AAEDU,EAAAA,QAAQ,CAACV,cAAD,EAAiC;AAAA;;AAEvC,6BAAKS,UAAL,+FAAiBC,QAAjB,uGAA4BV,cAA5B;AAEA,8BAAKS,UAAL,iGAAiBE,KAAjB,wGAAyBX,cAAzB;AACD;;AAEDY,EAAAA,UAAU,CAACZ,cAAD,EAAiC;AAAA;;AAEzC,8BAAKS,UAAL,iGAAiBG,UAAjB,wGAA8BZ,cAA9B;AAEA,8BAAKS,UAAL,iGAAiBI,OAAjB,wGAA2Bb,cAA3B;AACD;;AA/B+C","sourcesContent":["import type {DeviceProps} from '@luma.gl/api';\nimport type {AnimationProps} from '../lib/animation-props';\nimport AnimationLoop from './animation-loop';\n\n/**\n * Minimal animation loop that initializes models in constructor\n * Simplifying type management\n * v9 API\n */\nexport abstract class RenderLoop {\n constructor(animationProps?: AnimationProps) {}\n\n /** Instantiates and runs the render loop */\n static run(RenderLoopConstructor: typeof RenderLoop, deviceProps?: DeviceProps): AnimationLoop {\n // Create an animation loop;\n const animationLoop = new SyncInitAnimationLoop(RenderLoopConstructor, deviceProps);\n\n // Start the loop automatically\n // animationLoop.start();\n\n return animationLoop;\n }\n}\n\n/** Instantiates the RenderLoop once the device is created */\nclass SyncInitAnimationLoop extends AnimationLoop {\n RenderLoopConstructor: typeof RenderLoop;\n renderLoop: RenderLoop;\n\n getInfo() {\n // @ts-ignore\n return this.RenderLoopConstructor.info;\n }\n\n constructor(RenderLoopConstructor: typeof RenderLoop, deviceProps?: DeviceProps) {\n super({deviceProps});\n this.RenderLoopConstructor = RenderLoopConstructor;\n }\n\n onInitialize(animationProps: AnimationProps) {\n // @ts-expect-error\n this.renderLoop = new this.RenderLoopConstructor(animationProps);\n }\n\n onRender(animationProps: AnimationProps) {\n // @ts-expect-error API still TBD\n this.renderLoop?.onRender?.(animationProps);\n // @ts-expect-error API still TBD\n this.renderLoop?.frame?.(animationProps);\n }\n\n onFinalize(animationProps: AnimationProps) {\n // @ts-expect-error API still TBD\n this.renderLoop?.onFinalize?.(animationProps);\n // @ts-expect-error API still TBD\n this.renderLoop?.destroy?.(animationProps);\n }\n}\n"],"file":"render-loop.js"}
|
package/src/bundle.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
import type {GeometryTable} from './geometry-table';
|
|
3
|
-
|
|
4
|
-
export function unpackIndexedGeometry(geometry: GeometryTable): GeometryTable {
|
|
5
|
-
const {indices, attributes} = geometry;
|
|
6
|
-
if (!indices) {
|
|
7
|
-
return geometry;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const vertexCount = indices.length;
|
|
11
|
-
const unpackedAttributes = {};
|
|
12
|
-
|
|
13
|
-
for (const [name, values] of Object.entries(attributes)) {
|
|
14
|
-
const size = {POSITION: 3, NORMAL: 3, TEX_COORD0: 2}[name];
|
|
15
|
-
const unpackedValues = new values.constructor(length * size);
|
|
16
|
-
for (let x = 0; x < vertexCount; ++x) {
|
|
17
|
-
const index = indices[x];
|
|
18
|
-
for (let i = 0; i < size; i++) {
|
|
19
|
-
unpackedValues[x * size + i] = values[index * size + i];
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
unpackedAttributes[name] = unpackedValues;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return {
|
|
26
|
-
length,
|
|
27
|
-
attributes: unpackedAttributes
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
*/
|
package/src/lib/model-utils.ts
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import {Device, Buffer, assert} from '@luma.gl/api';
|
|
2
|
-
import type Geometry from '../geometry/geometry';
|
|
3
|
-
|
|
4
|
-
// Support for mapping new geometries with glTF attribute names to "classic" luma.gl shader names
|
|
5
|
-
const GLTF_TO_LUMA_ATTRIBUTE_MAP = {
|
|
6
|
-
POSITION: 'positions',
|
|
7
|
-
NORMAL: 'normals',
|
|
8
|
-
COLOR_0: 'colors',
|
|
9
|
-
TEXCOORD_0: 'texCoords',
|
|
10
|
-
TEXCOORD_1: 'texCoords1',
|
|
11
|
-
TEXCOORD_2: 'texCoords2'
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
/*
|
|
15
|
-
export function getAttributeLayoutsFromGeometry(geometry: Geometry) {
|
|
16
|
-
const layouts: Record<string, {}> = {};
|
|
17
|
-
let indices = geometry.indices;
|
|
18
|
-
|
|
19
|
-
for (const [name, attribute] of Object.entries(geometry.attributes)) {
|
|
20
|
-
const remappedName = mapAttributeName(name);
|
|
21
|
-
|
|
22
|
-
if (attribute.constant) {
|
|
23
|
-
throw new Error('constant attributes not supported');
|
|
24
|
-
} else {
|
|
25
|
-
const typedArray = attribute.value;
|
|
26
|
-
// Create accessor by copying the attribute and removing `value``
|
|
27
|
-
const accessor = {...attribute};
|
|
28
|
-
delete accessor.value;
|
|
29
|
-
buffers[remappedName] = [device.createBuffer(typedArray), accessor];
|
|
30
|
-
|
|
31
|
-
inferAttributeAccessor(name, accessor);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export class Table {
|
|
37
|
-
length: number;
|
|
38
|
-
// columns: Record<string, TypedArray> = {};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export class GPUTable {
|
|
42
|
-
length: number;
|
|
43
|
-
columns: Record<string, Buffer> = {};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function convertTableToGPUTable(table: Table) {
|
|
47
|
-
// for (const ) {}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function renameTableColumns(table: Table, map: (name: string) => string) {
|
|
51
|
-
const newColumns = table.columns.reduce()
|
|
52
|
-
table.clone();
|
|
53
|
-
}
|
|
54
|
-
*/
|
|
55
|
-
|
|
56
|
-
export function getIndexBufferFromGeometry(device: Device, geometry: Geometry): Buffer | undefined {
|
|
57
|
-
if (!geometry.indices) {
|
|
58
|
-
return undefined;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// @ts-expect-error
|
|
62
|
-
const data = geometry.indices.value || geometry.indices;
|
|
63
|
-
assert(
|
|
64
|
-
data instanceof Uint16Array || data instanceof Uint32Array,
|
|
65
|
-
'attribute array for "indices" must be of integer type'
|
|
66
|
-
);
|
|
67
|
-
return device.createBuffer({usage: Buffer.INDEX, data});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export function getAttributeBuffersFromGeometry(device: Device, geometry: Geometry): Record<string, Buffer> {
|
|
71
|
-
const buffers: Record<string, Buffer> = {};
|
|
72
|
-
|
|
73
|
-
for (const [name, attribute] of Object.entries(geometry.attributes)) {
|
|
74
|
-
const remappedName = mapAttributeName(name);
|
|
75
|
-
if (attribute.constant) {
|
|
76
|
-
throw new Error('constant attributes not supported');
|
|
77
|
-
} else {
|
|
78
|
-
const typedArray = attribute.value;
|
|
79
|
-
buffers[remappedName] = device.createBuffer({data: typedArray, id: `${remappedName}-buffer`});
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return buffers;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function mapAttributeName(name: string): string {
|
|
87
|
-
return GLTF_TO_LUMA_ATTRIBUTE_MAP[name] || name;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/*
|
|
91
|
-
// Check for well known attribute names
|
|
92
|
-
// eslint-disable-next-line complexity
|
|
93
|
-
export function inferAttributeAccessor(attributeName, attribute) {
|
|
94
|
-
let category;
|
|
95
|
-
switch (attributeName) {
|
|
96
|
-
case 'texCoords':
|
|
97
|
-
case 'texCoord1':
|
|
98
|
-
case 'texCoord2':
|
|
99
|
-
case 'texCoord3':
|
|
100
|
-
category = 'uvs';
|
|
101
|
-
break;
|
|
102
|
-
case 'vertices':
|
|
103
|
-
case 'positions':
|
|
104
|
-
case 'normals':
|
|
105
|
-
case 'pickingColors':
|
|
106
|
-
category = 'vectors';
|
|
107
|
-
break;
|
|
108
|
-
default:
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Check for categorys
|
|
112
|
-
switch (category) {
|
|
113
|
-
case 'vectors':
|
|
114
|
-
attribute.size = attribute.size || 3;
|
|
115
|
-
break;
|
|
116
|
-
case 'uvs':
|
|
117
|
-
attribute.size = attribute.size || 2;
|
|
118
|
-
break;
|
|
119
|
-
default:
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
assert(Number.isFinite(attribute.size), `attribute ${attributeName} needs size`);
|
|
123
|
-
}
|
|
124
|
-
*/
|