UNPKG

@babylonjs/viewer

Version:

The Babylon Viewer aims to simplify a specific but common Babylon.js use case: loading, viewing, and interacting with a 3D model.

3 lines (2 loc) 2.38 kB
import{f as e,B as r,F as t,j as n,U as a,t as o,k as i,l as s,g as f,m as c,n as l}from"./index-B8IgtevW.esm.min.js";import{s as u}from"./skybox.vertex-Ban7q6IM-DcsSq_1-.esm.min.js";import{W as d}from"./wgsl-helpers-CJmgf3KG.esm.min.js";const p=[{arrayStride:12,attributes:[{shaderLocation:0,offset:0,format:"float32x3"}]}],m=new Map;let b=null,_=null;function v(x,g,B,h,y){const k=x.surface.engine,w=x.clearColor,M=function(n,o){const i=new t([-o,-o,-o,o,-o,-o,-o,o,-o,o,o,-o,-o,-o,o,o,-o,o,-o,o,o,o,o,o]),s=new a([6,4,5,7,6,5,0,2,3,1,0,3,5,1,3,7,5,3,0,4,6,2,0,6,3,2,6,7,3,6,0,1,5,4,0,5]);return{posBuffer:e(n,i,r.VERTEX),idxBuffer:e(n,s,r.INDEX)}}(k,B),C=function(){function e(e){const r=e._device;return b&&_===r||(b=c(e,"skybox-material",l.VERTEX|l.FRAGMENT)),b}return{getPipeline(r,t){const n=r._device;_!==n&&(m.clear(),b=null,_=n);const a=o(t),c=m.get(a);if(c)return c;const l=n.createShaderModule({code:i+u,label:"skybox-vert"}),v=n.createShaderModule({code:d+"struct c{world:mat4x4<f32>,primaryColor:vec3<f32>,_pad:f32,skyOutputColor:vec3<f32>,_pad2:f32}@group(1) @binding(0) var<uniform> mesh:c;struct d{@location(0) positionUVW:vec3<f32>,@location(1) positionW:vec3<f32>}@fragment fn main(b:d)->@location(0) vec4<f32>{var a=vec4<f32>(mesh.skyOutputColor,1.0);a=vec4<f32>(a.rgb+vec3<f32>(dither(b.positionW.xy,0.5)),a.a);a=max(a,vec4<f32>(0.0));return a;}",label:"skybox-frag"}),x=n.createRenderPipeline(s({_label:"skybox-pipeline",_engine:r,_bgls:[f(r),e(r)],_vertModule:l,_fragModule:v,_vertexBuffers:p,_format:t._colorFormat,_depthStencilFormat:t._depthStencilFormat,_depthCompare:t._depthCompare,_msaaSamples:t._sampleCount,_depthWriteEnabled:!1}));return m.set(a,x),x},createBindGroup:(r,t,n)=>r._device.createBindGroup({layout:e(r),entries:[{binding:0,resource:{buffer:t}}]})}}(),E=[w.r,w.g,w.b],S=function(e,r,a,o){const i=new t(24);return i[0]=i[5]=i[10]=i[15]=1,i[12]=r[0],i[13]=r[1],i[14]=r[2],i[16]=a[0],i[17]=a[1],i[18]=a[2],i[20]=o[0],i[21]=o[1],i[22]=o[2],n(e,i)}(k,h,y,E),F=C.createBindGroup(k,S,g),G={order:0,isTransparent:!1,bind:(e,r)=>({renderable:G,pipeline:C.getPipeline(e,r),draw:e=>(e.setBindGroup(1,F),e.setVertexBuffer(0,M.posBuffer),e.setIndexBuffer(M.idxBuffer,"uint16"),e.drawIndexed(36),1)}),_rebuild:()=>v(x,g,B,h,y)};return G}export{v as buildSolidSkyboxRenderable}; //# sourceMappingURL=background-solid-skybox-BlAFqRVA.esm.min.js.map