macaw-threejs
Version:
Macaw Three.js is ready to use library to connect Three.js with your project.<br/> Under the hood is a fully optimized, clean Three.js set up to make it easy to implement effects for images (future text, etc.). With effects out of the box, you don't even
2 lines (1 loc) • 1.23 kB
JavaScript
import*as e from"three";import{SCENE_DEFAULTS as r}from"./constants.js";import{MacawComposerShader as n}from"./Core/Shader/Composer.js";import{MacawImageShader as t}from"./Core/Shader/Image.js";import{calculateCameraFov as a}from"./utils/calculate_camera_fov.js";function o({settings:r}){const n=new e.Scene;return r.alpha||(n.background=new e.Color(r.color)),n}function i({dimensions:n}){const t=new e.PerspectiveCamera(r.cameraFov,n.width/n.height,r.near,r.far);return t.position.z=r.positionZ,t.position.y=0,t.fov=a(n.height,t.position.z),t}function s({container:r,settings:n}){const t=new e.WebGLRenderer({powerPreference:"high-performance",alpha:n.alpha});return t.setPixelRatio(Math.min(devicePixelRatio,n.maxDPR)),r.appendChild(t.domElement),t}function m(){const n=new e.Raycaster;return n.near=r.near,n.far=r.far,n}function f(){const r=new t;return{shader:r,baseMaterial:new e.ShaderMaterial({uniforms:r.uniforms,fragmentShader:r.fragmentShader,vertexShader:r.vertexShader})}}function c(){const e=new n;return{shader:e,shaderEffect:{uniforms:e.uniforms,fragmentShader:e.fragmentShader,vertexShader:e.vertexShader}}}export{i as initCamera,c as initComposer,f as initImage,m as initRaycaster,s as initRenderer,o as initScene};