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.4 kB
import{d as e,B as r,F as t,e as n,U as o,t as a,f as s,g as i,h as f,S as c}from"./index-DFZFpUG-.esm.min.js";import{s as u}from"./skybox.vertex-Ban7q6IM-DcsSq_1-.esm.min.js";import{W as l}from"./wgsl-helpers-CJmgf3KG.esm.min.js";import{S as d}from"./scene-uniforms-Cr9D1h23.esm.min.js";const p=[{arrayStride:12,attributes:[{shaderLocation:0,offset:0,format:"float32x3"}]}],m=new Map;let b=null,_=null;function v(v,x,g,B,h){const y=v.surface.engine,w=v.clearColor,C=function(n,a){const s=new t([-a,-a,-a,a,-a,-a,-a,a,-a,a,a,-a,-a,-a,a,a,-a,a,-a,a,a,a,a,a]),i=new o([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,s,r.VERTEX),idxBuffer:e(n,i,r.INDEX)}}(y,g),S=function(){function e(e){const r=e._device;return b&&_===r||(b=f(e,"skybox-material",c.VERTEX|c.FRAGMENT)),b}return{getPipeline(r,t){const n=r._device;_!==n&&(m.clear(),b=null,_=n);const o=a(t),f=m.get(o);if(f)return f;const c=n.createShaderModule({code:d+u,label:"skybox-vert"}),v=n.createShaderModule({code:l+"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:[i(r),e(r)],_vertModule:c,_fragModule:v,_vertexBuffers:p,_format:t._colorFormat,_depthStencilFormat:t._depthStencilFormat,_depthCompare:t._depthCompare,_msaaSamples:t._sampleCount,_depthWriteEnabled:!1}));return m.set(o,x),x},createBindGroup:(r,t,n)=>r._device.createBindGroup({layout:e(r),entries:[{binding:0,resource:{buffer:t}}]})}}(),k=function(e,r,o,a){const s=new t(24);return s[0]=s[5]=s[10]=s[15]=1,s[12]=r[0],s[13]=r[1],s[14]=r[2],s[16]=o[0],s[17]=o[1],s[18]=o[2],s[20]=a[0],s[21]=a[1],s[22]=a[2],n(e,s)}(y,B,h,[w.r,w.g,w.b]),E=S.createBindGroup(y,k,x),M={order:0,isTransparent:!1,bind:(e,r)=>({renderable:M,pipeline:S.getPipeline(e,r),draw:e=>(e.setBindGroup(1,E),e.setVertexBuffer(0,C.posBuffer),e.setIndexBuffer(C.idxBuffer,"uint16"),e.drawIndexed(36),1)})};return M}export{v as buildSolidSkyboxRenderable}; //# sourceMappingURL=background-solid-skybox-otxSKHeJ.esm.min.js.map