├── apps └── ptk │ ├── __init__.py │ ├── app │ ├── style2.css │ ├── 2024.png │ ├── preload.js │ ├── theme.json │ ├── templates.json │ └── index.html │ └── package.json ├── src ├── assets │ ├── ComicSans.ttf │ ├── app │ │ ├── icon.icns │ │ ├── icon.ico │ │ └── icon.png │ ├── modules │ │ ├── three-addons │ │ │ ├── libs │ │ │ │ ├── ammo.wasm.wasm │ │ │ │ ├── rhino3dm │ │ │ │ │ └── rhino3dm.wasm │ │ │ │ ├── draco │ │ │ │ │ ├── draco_decoder.wasm │ │ │ │ │ ├── gltf │ │ │ │ │ │ └── draco_decoder.wasm │ │ │ │ │ └── README.md │ │ │ │ └── basis │ │ │ │ │ └── basis_transcoder.wasm │ │ │ ├── nodes │ │ │ │ ├── core │ │ │ │ │ ├── NodeParser.js │ │ │ │ │ ├── UniformGroup.js │ │ │ │ │ ├── NodeVar.js │ │ │ │ │ ├── NodeAttribute.js │ │ │ │ │ ├── NodeCode.js │ │ │ │ │ ├── NodeVarying.js │ │ │ │ │ ├── NodeCache.js │ │ │ │ │ ├── NodeFunctionInput.js │ │ │ │ │ ├── LightingModel.js │ │ │ │ │ ├── StructTypeNode.js │ │ │ │ │ ├── NodeFunction.js │ │ │ │ │ ├── ArrayUniformNode.js │ │ │ │ │ ├── NodeUniform.js │ │ │ │ │ ├── ConstNode.js │ │ │ │ │ ├── ParameterNode.js │ │ │ │ │ ├── constants.js │ │ │ │ │ ├── UniformGroupNode.js │ │ │ │ │ ├── BypassNode.js │ │ │ │ │ ├── CacheNode.js │ │ │ │ │ ├── VarNode.js │ │ │ │ │ ├── ContextNode.js │ │ │ │ │ ├── IndexNode.js │ │ │ │ │ ├── NodeKeywords.js │ │ │ │ │ ├── OutputStructNode.js │ │ │ │ │ ├── TempNode.js │ │ │ │ │ └── AssignNode.js │ │ │ │ ├── functions │ │ │ │ │ ├── BSDF │ │ │ │ │ │ ├── BRDF_Lambert.js │ │ │ │ │ │ ├── EnvironmentBRDF.js │ │ │ │ │ │ ├── Schlick_to_F0.js │ │ │ │ │ │ ├── F_Schlick.js │ │ │ │ │ │ ├── D_GGX.js │ │ │ │ │ │ ├── DFGApprox.js │ │ │ │ │ │ ├── V_GGX_SmithCorrelated.js │ │ │ │ │ │ └── BRDF_GGX.js │ │ │ │ │ └── material │ │ │ │ │ │ ├── getGeometryRoughness.js │ │ │ │ │ │ └── getRoughness.js │ │ │ │ ├── parsers │ │ │ │ │ └── GLSLNodeParser.js │ │ │ │ ├── lighting │ │ │ │ │ ├── LightingNode.js │ │ │ │ │ ├── AONode.js │ │ │ │ │ ├── AmbientLightNode.js │ │ │ │ │ ├── LightUtils.js │ │ │ │ │ ├── IESSpotLightNode.js │ │ │ │ │ ├── DirectionalLightNode.js │ │ │ │ │ └── LightNode.js │ │ │ │ ├── accessors │ │ │ │ │ ├── PointUVNode.js │ │ │ │ │ ├── TextureStoreNode.js │ │ │ │ │ ├── InstancedPointsMaterialNode.js │ │ │ │ │ ├── StorageBufferNode.js │ │ │ │ │ ├── BufferNode.js │ │ │ │ │ ├── UserDataNode.js │ │ │ │ │ ├── ReflectVectorNode.js │ │ │ │ │ ├── UVNode.js │ │ │ │ │ ├── TextureSizeNode.js │ │ │ │ │ ├── ModelViewProjectionNode.js │ │ │ │ │ ├── ModelNode.js │ │ │ │ │ ├── CubeTextureNode.js │ │ │ │ │ ├── MaterialReferenceNode.js │ │ │ │ │ └── SceneNode.js │ │ │ │ ├── display │ │ │ │ │ ├── FrontFacingNode.js │ │ │ │ │ ├── PosterizeNode.js │ │ │ │ │ ├── ViewportSharedTextureNode.js │ │ │ │ │ └── ViewportDepthTextureNode.js │ │ │ │ ├── materials │ │ │ │ │ ├── LineBasicNodeMaterial.js │ │ │ │ │ ├── MeshBasicNodeMaterial.js │ │ │ │ │ ├── PointsNodeMaterial.js │ │ │ │ │ ├── MeshLambertNodeMaterial.js │ │ │ │ │ ├── MeshNormalNodeMaterial.js │ │ │ │ │ └── Materials.js │ │ │ │ ├── fog │ │ │ │ │ ├── FogNode.js │ │ │ │ │ ├── FogRangeNode.js │ │ │ │ │ └── FogExp2Node.js │ │ │ │ ├── utils │ │ │ │ │ ├── ArrayElementNode.js │ │ │ │ │ ├── DiscardNode.js │ │ │ │ │ ├── MatcapUVNode.js │ │ │ │ │ ├── EquirectUVNode.js │ │ │ │ │ ├── MaxMipLevelNode.js │ │ │ │ │ ├── SpriteSheetUVNode.js │ │ │ │ │ ├── SpecularMIPLevelNode.js │ │ │ │ │ ├── RemapNode.js │ │ │ │ │ ├── RotateUVNode.js │ │ │ │ │ ├── ConvertNode.js │ │ │ │ │ ├── PackingNode.js │ │ │ │ │ ├── JoinNode.js │ │ │ │ │ └── SetNode.js │ │ │ │ ├── code │ │ │ │ │ └── ExpressionNode.js │ │ │ │ ├── math │ │ │ │ │ └── HashNode.js │ │ │ │ ├── procedural │ │ │ │ │ └── CheckerNode.js │ │ │ │ ├── materialx │ │ │ │ │ └── lib │ │ │ │ │ │ └── mx_transform_color.js │ │ │ │ └── loaders │ │ │ │ │ ├── NodeMaterialLoader.js │ │ │ │ │ └── NodeObjectLoader.js │ │ │ ├── renderers │ │ │ │ ├── common │ │ │ │ │ ├── Pipeline.js │ │ │ │ │ ├── UniformBuffer.js │ │ │ │ │ ├── ProgrammableStage.js │ │ │ │ │ ├── nodes │ │ │ │ │ │ ├── NodeSampler.js │ │ │ │ │ │ ├── NodeUniformsGroup.js │ │ │ │ │ │ ├── NodeBuilderState.js │ │ │ │ │ │ └── NodeSampledTexture.js │ │ │ │ │ ├── Constants.js │ │ │ │ │ ├── Sampler.js │ │ │ │ │ ├── StorageBuffer.js │ │ │ │ │ ├── ComputePipeline.js │ │ │ │ │ ├── RenderPipeline.js │ │ │ │ │ ├── Binding.js │ │ │ │ │ ├── StorageTexture.js │ │ │ │ │ ├── Color4.js │ │ │ │ │ ├── PostProcessing.js │ │ │ │ │ ├── Buffer.js │ │ │ │ │ ├── RenderLists.js │ │ │ │ │ ├── DataMap.js │ │ │ │ │ ├── BufferUtils.js │ │ │ │ │ ├── Animation.js │ │ │ │ │ ├── RenderContext.js │ │ │ │ │ ├── Info.js │ │ │ │ │ └── ChainMap.js │ │ │ │ ├── webgpu │ │ │ │ │ ├── nodes │ │ │ │ │ │ └── WGSLNodeParser.js │ │ │ │ │ └── WebGPURenderer.js │ │ │ │ ├── webgl-legacy │ │ │ │ │ └── nodes │ │ │ │ │ │ ├── SlotNode.js │ │ │ │ │ │ └── WebGLNodes.js │ │ │ │ └── webgl │ │ │ │ │ └── utils │ │ │ │ │ ├── WebGLExtensions.js │ │ │ │ │ └── WebGLCapabilities.js │ │ │ ├── offscreen │ │ │ │ ├── offscreen.js │ │ │ │ └── jank.js │ │ │ ├── transpiler │ │ │ │ ├── Transpiler.js │ │ │ │ └── ShaderToyDecoder.js │ │ │ ├── shaders │ │ │ │ ├── BasicShader.js │ │ │ │ ├── ExposureShader.js │ │ │ │ ├── CopyShader.js │ │ │ │ ├── GammaCorrectionShader.js │ │ │ │ ├── LuminosityShader.js │ │ │ │ ├── UnpackDepthRGBAShader.js │ │ │ │ ├── ColorifyShader.js │ │ │ │ ├── BlendShader.js │ │ │ │ ├── ColorCorrectionShader.js │ │ │ │ ├── TechnicolorShader.js │ │ │ │ ├── VignetteShader.js │ │ │ │ ├── AfterimageShader.js │ │ │ │ ├── MirrorShader.js │ │ │ │ ├── SepiaShader.js │ │ │ │ ├── DOFMipMapShader.js │ │ │ │ ├── FilmShader.js │ │ │ │ ├── NormalMapShader.js │ │ │ │ ├── KaleidoShader.js │ │ │ │ ├── BrightnessContrastShader.js │ │ │ │ ├── RGBShiftShader.js │ │ │ │ ├── BleachBypassShader.js │ │ │ │ ├── LuminosityHighPassShader.js │ │ │ │ └── DotScreenShader.js │ │ │ ├── lights │ │ │ │ └── IESSpotLight.js │ │ │ ├── lines │ │ │ │ ├── Line2.js │ │ │ │ └── WireframeGeometry2.js │ │ │ ├── objects │ │ │ │ ├── InstancedPoints.js │ │ │ │ └── QuadMesh.js │ │ │ ├── loaders │ │ │ │ └── TIFFLoader.js │ │ │ ├── math │ │ │ │ └── ColorConverter.js │ │ │ ├── controls │ │ │ │ └── MapControls.js │ │ │ ├── textures │ │ │ │ └── FlakesTexture.js │ │ │ ├── postprocessing │ │ │ │ ├── ClearPass.js │ │ │ │ └── FilmPass.js │ │ │ ├── webxr │ │ │ │ └── Text2D.js │ │ │ ├── capabilities │ │ │ │ └── WebGPU.js │ │ │ ├── geometries │ │ │ │ ├── ConvexGeometry.js │ │ │ │ └── TextGeometry.js │ │ │ ├── effects │ │ │ │ └── StereoEffect.js │ │ │ ├── misc │ │ │ │ ├── MorphAnimMesh.js │ │ │ │ └── Gyroscope.js │ │ │ ├── curves │ │ │ │ └── NURBSSurface.js │ │ │ └── environments │ │ │ │ └── DebugEnvironment.js │ │ ├── highlight-light.min.css │ │ └── highlight-dark.min.css │ ├── icons │ │ ├── merge.svg │ │ ├── jump.svg │ │ ├── export.svg │ │ ├── array.svg │ │ ├── variable.svg │ │ └── robot.svg │ ├── logo-part-solid.svg │ ├── logo-part-2.svg │ ├── logo-part-1.svg │ ├── logo-part-4.svg │ └── logo-part-3.svg ├── sources │ ├── wpilog │ │ ├── util.js │ │ └── source.js │ ├── ds │ │ ├── util.js │ │ └── source.js │ └── csv │ │ ├── time │ │ └── source.js │ │ └── field │ │ └── source.js ├── planner │ ├── index.html │ └── solver │ │ ├── constants.py │ │ ├── motor.py │ │ └── util.py ├── panel │ ├── index.html │ └── tabs │ │ ├── tooltab.js │ │ └── scouttab.js ├── modal │ ├── style-modal.css │ ├── index.html │ ├── progress │ │ └── app.js │ └── alert │ │ └── app.js ├── pit │ ├── index.html │ └── style.css └── pythontk │ └── index.html ├── .gitignore └── docs ├── pit └── MAIN.md ├── panel └── tabs │ ├── SCOUT.md │ ├── WEBVIEW.md │ ├── TABLE.md │ ├── ADD.md │ ├── LOGGER.md │ └── VIDSYNC.md └── pythontk └── MAIN.md /apps/ptk/__init__.py: -------------------------------------------------------------------------------- 1 | import ptk.util 2 | from ptk.odom2d import Odometry2d 3 | -------------------------------------------------------------------------------- /apps/ptk/app/style2.css: -------------------------------------------------------------------------------- 1 | .odom { 2 | width: 100%; 3 | height: 100%; 4 | } -------------------------------------------------------------------------------- /apps/ptk/app/2024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/team6036/peninsulaportal/HEAD/apps/ptk/app/2024.png -------------------------------------------------------------------------------- /src/assets/ComicSans.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/team6036/peninsulaportal/HEAD/src/assets/ComicSans.ttf -------------------------------------------------------------------------------- /src/assets/app/icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/team6036/peninsulaportal/HEAD/src/assets/app/icon.icns -------------------------------------------------------------------------------- /src/assets/app/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/team6036/peninsulaportal/HEAD/src/assets/app/icon.ico -------------------------------------------------------------------------------- /src/assets/app/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/team6036/peninsulaportal/HEAD/src/assets/app/icon.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea 3 | 4 | node_modules 5 | __pycache__ 6 | 7 | apps/**/package-lock.json 8 | 9 | build 10 | dist 11 | temp -------------------------------------------------------------------------------- /src/assets/modules/three-addons/libs/ammo.wasm.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/team6036/peninsulaportal/HEAD/src/assets/modules/three-addons/libs/ammo.wasm.wasm -------------------------------------------------------------------------------- /src/assets/modules/three-addons/libs/rhino3dm/rhino3dm.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/team6036/peninsulaportal/HEAD/src/assets/modules/three-addons/libs/rhino3dm/rhino3dm.wasm -------------------------------------------------------------------------------- /src/assets/modules/three-addons/libs/draco/draco_decoder.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/team6036/peninsulaportal/HEAD/src/assets/modules/three-addons/libs/draco/draco_decoder.wasm -------------------------------------------------------------------------------- /src/assets/modules/three-addons/libs/basis/basis_transcoder.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/team6036/peninsulaportal/HEAD/src/assets/modules/three-addons/libs/basis/basis_transcoder.wasm -------------------------------------------------------------------------------- /src/assets/modules/three-addons/libs/draco/gltf/draco_decoder.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/team6036/peninsulaportal/HEAD/src/assets/modules/three-addons/libs/draco/gltf/draco_decoder.wasm -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/core/NodeParser.js: -------------------------------------------------------------------------------- 1 | class NodeParser { 2 | 3 | parseFunction( /*source*/ ) { 4 | 5 | console.warn( 'Abstract function.' ); 6 | 7 | } 8 | 9 | } 10 | 11 | export default NodeParser; 12 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/core/UniformGroup.js: -------------------------------------------------------------------------------- 1 | class UniformGroup { 2 | 3 | constructor( name ) { 4 | 5 | this.name = name; 6 | 7 | this.isUniformGroup = true; 8 | 9 | } 10 | 11 | } 12 | 13 | export default UniformGroup; 14 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/renderers/common/Pipeline.js: -------------------------------------------------------------------------------- 1 | class Pipeline { 2 | 3 | constructor( cacheKey ) { 4 | 5 | this.cacheKey = cacheKey; 6 | 7 | this.usedTimes = 0; 8 | 9 | } 10 | 11 | } 12 | 13 | export default Pipeline; 14 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/core/NodeVar.js: -------------------------------------------------------------------------------- 1 | class NodeVar { 2 | 3 | constructor( name, type ) { 4 | 5 | this.isNodeVar = true; 6 | 7 | this.name = name; 8 | this.type = type; 9 | 10 | } 11 | 12 | } 13 | 14 | export default NodeVar; 15 | -------------------------------------------------------------------------------- /docs/pit/MAIN.md: -------------------------------------------------------------------------------- 1 | ← Back 2 | 3 |
4 |

Peninsula Pit

5 |

A simple pit display

6 |
7 | 8 | im working on it :P i dont think this does anything yet 9 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/offscreen/offscreen.js: -------------------------------------------------------------------------------- 1 | import init from './scene.js'; 2 | 3 | self.onmessage = function ( message ) { 4 | 5 | const data = message.data; 6 | init( data.drawingSurface, data.width, data.height, data.pixelRatio, data.path ); 7 | 8 | }; 9 | -------------------------------------------------------------------------------- /apps/ptk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "app/main.js", 3 | "scripts": { 4 | "start": "electron app/main.js" 5 | }, 6 | "dependencies": { 7 | "ionicons": "^7.1.2", 8 | "mathjs": "^12.3.0", 9 | "three": "^0.160.0" 10 | }, 11 | "devDependencies": { 12 | "electron": "^28.2.0" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/core/NodeAttribute.js: -------------------------------------------------------------------------------- 1 | class NodeAttribute { 2 | 3 | constructor( name, type, node = null ) { 4 | 5 | this.isNodeAttribute = true; 6 | 7 | this.name = name; 8 | this.type = type; 9 | this.node = node; 10 | 11 | } 12 | 13 | } 14 | 15 | export default NodeAttribute; 16 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/functions/BSDF/BRDF_Lambert.js: -------------------------------------------------------------------------------- 1 | import { tslFn } from '../../shadernode/ShaderNode.js'; 2 | 3 | const BRDF_Lambert = tslFn( ( inputs ) => { 4 | 5 | return inputs.diffuseColor.mul( 1 / Math.PI ); // punctual light 6 | 7 | } ); // validated 8 | 9 | export default BRDF_Lambert; 10 | -------------------------------------------------------------------------------- /apps/ptk/app/preload.js: -------------------------------------------------------------------------------- 1 | const { ipcRenderer, contextBridge } = require("electron"); 2 | 3 | contextBridge.exposeInMainWorld("api", { 4 | sendReady: () => ipcRenderer.send("ready"), 5 | onData: f => { 6 | ipcRenderer.on("data", f); 7 | return () => ipcRenderer.removeListener("data", f); 8 | }, 9 | }); 10 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/core/NodeCode.js: -------------------------------------------------------------------------------- 1 | class NodeCode { 2 | 3 | constructor( name, type, code = '' ) { 4 | 5 | this.name = name; 6 | this.type = type; 7 | this.code = code; 8 | 9 | Object.defineProperty( this, 'isNodeCode', { value: true } ); 10 | 11 | } 12 | 13 | } 14 | 15 | export default NodeCode; 16 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/renderers/common/UniformBuffer.js: -------------------------------------------------------------------------------- 1 | import Buffer from './Buffer.js'; 2 | 3 | class UniformBuffer extends Buffer { 4 | 5 | constructor( name, buffer = null ) { 6 | 7 | super( name, buffer ); 8 | 9 | this.isUniformBuffer = true; 10 | 11 | } 12 | 13 | } 14 | 15 | export default UniformBuffer; 16 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/renderers/common/ProgrammableStage.js: -------------------------------------------------------------------------------- 1 | let _id = 0; 2 | 3 | class ProgrammableStage { 4 | 5 | constructor( code, type ) { 6 | 7 | this.id = _id ++; 8 | 9 | this.code = code; 10 | this.stage = type; 11 | 12 | this.usedTimes = 0; 13 | 14 | } 15 | 16 | } 17 | 18 | export default ProgrammableStage; 19 | -------------------------------------------------------------------------------- /src/sources/wpilog/util.js: -------------------------------------------------------------------------------- 1 | import * as util from "../../util.mjs"; 2 | import * as lib from "../../lib.mjs"; 3 | 4 | 5 | export const HEADERSTRING = "WPILOG"; 6 | export const HEADERVERSION = 0x0100; 7 | export const CONTROLENTRY = 0; 8 | export const CONTROLSTART = 0; 9 | export const CONTROLFINISH = 1; 10 | export const CONTROLMETADATA = 2; 11 | -------------------------------------------------------------------------------- /docs/panel/tabs/SCOUT.md: -------------------------------------------------------------------------------- 1 | ← Back 2 | 3 | # Scout Tab 4 | 5 | Embeds external scouting tool if applicable. This tool must have a web address, and there must be WIFI access. 6 | 7 | ## Navigation 8 | Simply use your tool like normal. There is no navigation - it is simply an embed of whatever web address your tool is hosted at. 9 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/core/NodeVarying.js: -------------------------------------------------------------------------------- 1 | import NodeVar from './NodeVar.js'; 2 | 3 | class NodeVarying extends NodeVar { 4 | 5 | constructor( name, type ) { 6 | 7 | super( name, type ); 8 | 9 | this.needsInterpolation = false; 10 | 11 | this.isNodeVarying = true; 12 | 13 | } 14 | 15 | } 16 | 17 | export default NodeVarying; 18 | -------------------------------------------------------------------------------- /docs/pythontk/MAIN.md: -------------------------------------------------------------------------------- 1 | ← Back 2 | 3 |
4 |

Peninsula Python Toolkit

5 |

A way to use Peninsula Portal's graphical displays within Python

6 |
7 | 8 | ## Capabilities 9 | - im too lazy to do this rn. jus read the [docs](../../src/pythontk/doc.md) -------------------------------------------------------------------------------- /src/assets/modules/three-addons/transpiler/Transpiler.js: -------------------------------------------------------------------------------- 1 | class Transpiler { 2 | 3 | constructor( decoder, encoder ) { 4 | 5 | this.decoder = decoder; 6 | this.encoder = encoder; 7 | 8 | } 9 | 10 | parse( source ) { 11 | 12 | return this.encoder.emit( this.decoder.parse( source ) ); 13 | 14 | } 15 | 16 | } 17 | 18 | export default Transpiler; 19 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/parsers/GLSLNodeParser.js: -------------------------------------------------------------------------------- 1 | import NodeParser from '../core/NodeParser.js'; 2 | import GLSLNodeFunction from './GLSLNodeFunction.js'; 3 | 4 | class GLSLNodeParser extends NodeParser { 5 | 6 | parseFunction( source ) { 7 | 8 | return new GLSLNodeFunction( source ); 9 | 10 | } 11 | 12 | } 13 | 14 | export default GLSLNodeParser; 15 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/renderers/common/nodes/NodeSampler.js: -------------------------------------------------------------------------------- 1 | import Sampler from '../Sampler.js'; 2 | 3 | class NodeSampler extends Sampler { 4 | 5 | constructor( name, textureNode ) { 6 | 7 | super( name, textureNode ? textureNode.value : null ); 8 | 9 | this.textureNode = textureNode; 10 | 11 | } 12 | 13 | } 14 | 15 | export default NodeSampler; 16 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/renderers/common/Constants.js: -------------------------------------------------------------------------------- 1 | export const AttributeType = { 2 | VERTEX: 1, 3 | INDEX: 2, 4 | STORAGE: 4 5 | }; 6 | 7 | // size of a chunk in bytes (STD140 layout) 8 | 9 | export const GPU_CHUNK_BYTES = 16; 10 | 11 | // @TODO: Move to src/constants.js 12 | 13 | export const BlendColorFactor = 211; 14 | export const OneMinusBlendColorFactor = 212; 15 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/renderers/common/Sampler.js: -------------------------------------------------------------------------------- 1 | import Binding from './Binding.js'; 2 | 3 | class Sampler extends Binding { 4 | 5 | constructor( name, texture ) { 6 | 7 | super( name ); 8 | 9 | this.texture = texture; 10 | this.version = texture ? texture.version : 0; 11 | 12 | this.isSampler = true; 13 | 14 | } 15 | 16 | } 17 | 18 | export default Sampler; 19 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/renderers/common/StorageBuffer.js: -------------------------------------------------------------------------------- 1 | import Buffer from './Buffer.js'; 2 | 3 | class StorageBuffer extends Buffer { 4 | 5 | constructor( name, attribute ) { 6 | 7 | super( name, attribute ? attribute.array : null ); 8 | 9 | this.attribute = attribute; 10 | 11 | this.isStorageBuffer = true; 12 | 13 | } 14 | 15 | } 16 | 17 | export default StorageBuffer; 18 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/renderers/webgpu/nodes/WGSLNodeParser.js: -------------------------------------------------------------------------------- 1 | import NodeParser from '../../../nodes/core/NodeParser.js'; 2 | import WGSLNodeFunction from './WGSLNodeFunction.js'; 3 | 4 | class WGSLNodeParser extends NodeParser { 5 | 6 | parseFunction( source ) { 7 | 8 | return new WGSLNodeFunction( source ); 9 | 10 | } 11 | 12 | } 13 | 14 | export default WGSLNodeParser; 15 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/renderers/common/ComputePipeline.js: -------------------------------------------------------------------------------- 1 | import Pipeline from './Pipeline.js'; 2 | 3 | class ComputePipeline extends Pipeline { 4 | 5 | constructor( cacheKey, computeProgram ) { 6 | 7 | super( cacheKey ); 8 | 9 | this.computeProgram = computeProgram; 10 | 11 | this.isComputePipeline = true; 12 | 13 | } 14 | 15 | } 16 | 17 | export default ComputePipeline; 18 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/renderers/common/RenderPipeline.js: -------------------------------------------------------------------------------- 1 | import Pipeline from './Pipeline.js'; 2 | 3 | class RenderPipeline extends Pipeline { 4 | 5 | constructor( cacheKey, vertexProgram, fragmentProgram ) { 6 | 7 | super( cacheKey ); 8 | 9 | this.vertexProgram = vertexProgram; 10 | this.fragmentProgram = fragmentProgram; 11 | 12 | } 13 | 14 | } 15 | 16 | export default RenderPipeline; 17 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/lighting/LightingNode.js: -------------------------------------------------------------------------------- 1 | import Node, { addNodeClass } from '../core/Node.js'; 2 | 3 | class LightingNode extends Node { 4 | 5 | constructor() { 6 | 7 | super( 'vec3' ); 8 | 9 | } 10 | 11 | generate( /*builder*/ ) { 12 | 13 | console.warn( 'Abstract function.' ); 14 | 15 | } 16 | 17 | } 18 | 19 | export default LightingNode; 20 | 21 | addNodeClass( 'LightingNode', LightingNode ); 22 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/renderers/common/Binding.js: -------------------------------------------------------------------------------- 1 | class Binding { 2 | 3 | constructor( name = '' ) { 4 | 5 | this.name = name; 6 | 7 | this.visibility = 0; 8 | 9 | } 10 | 11 | setVisibility( visibility ) { 12 | 13 | this.visibility |= visibility; 14 | 15 | } 16 | 17 | clone() { 18 | 19 | return Object.assign( new this.constructor(), this ); 20 | 21 | } 22 | 23 | } 24 | 25 | export default Binding; 26 | -------------------------------------------------------------------------------- /src/sources/ds/util.js: -------------------------------------------------------------------------------- 1 | import * as util from "../../util.mjs"; 2 | import * as lib from "../../lib.mjs"; 3 | 4 | 5 | export function convertTime(s, part) { 6 | s = util.ensure(s, "num"); 7 | part = util.ensure(part, "num"); 8 | return -2082826800 + s + part/(2**64); 9 | } 10 | 11 | export function getPowerDistro(id) { 12 | if (id == 33) return "REV"; 13 | if (id == 25) return "CTRE"; 14 | return null; 15 | } 16 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/core/NodeCache.js: -------------------------------------------------------------------------------- 1 | let id = 0; 2 | 3 | class NodeCache { 4 | 5 | constructor() { 6 | 7 | this.id = id ++; 8 | this.nodesData = new WeakMap(); 9 | 10 | } 11 | 12 | getNodeData( node ) { 13 | 14 | return this.nodesData.get( node ); 15 | 16 | } 17 | 18 | setNodeData( node, data ) { 19 | 20 | this.nodesData.set( node, data ); 21 | 22 | } 23 | 24 | } 25 | 26 | export default NodeCache; 27 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/core/NodeFunctionInput.js: -------------------------------------------------------------------------------- 1 | class NodeFunctionInput { 2 | 3 | constructor( type, name, count = null, qualifier = '', isConst = false ) { 4 | 5 | this.type = type; 6 | this.name = name; 7 | this.count = count; 8 | this.qualifier = qualifier; 9 | this.isConst = isConst; 10 | 11 | } 12 | 13 | } 14 | 15 | NodeFunctionInput.isNodeFunctionInput = true; 16 | 17 | export default NodeFunctionInput; 18 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/core/LightingModel.js: -------------------------------------------------------------------------------- 1 | class LightingModel { 2 | 3 | start( /*input, stack, builder*/ ) { } 4 | 5 | finish( /*input, stack, builder*/ ) { } 6 | 7 | direct( /*input, stack, builder*/ ) { } 8 | 9 | indirectDiffuse( /*input, stack, builder*/ ) { } 10 | 11 | indirectSpecular( /*input, stack, builder*/ ) { } 12 | 13 | ambientOcclusion( /*input, stack, builder*/ ) { } 14 | 15 | } 16 | 17 | export default LightingModel; 18 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/renderers/common/StorageTexture.js: -------------------------------------------------------------------------------- 1 | import { Texture, LinearFilter } from 'three'; 2 | 3 | class StorageTexture extends Texture { 4 | 5 | constructor( width = 1, height = 1 ) { 6 | 7 | super(); 8 | 9 | this.image = { width, height }; 10 | 11 | this.magFilter = LinearFilter; 12 | this.minFilter = LinearFilter; 13 | 14 | this.isStorageTexture = true; 15 | 16 | } 17 | 18 | } 19 | 20 | export default StorageTexture; 21 | -------------------------------------------------------------------------------- /docs/panel/tabs/WEBVIEW.md: -------------------------------------------------------------------------------- 1 | ← Back 2 | 3 | # WebView Tab 4 | 5 | Displays a website. Works like any browser. 6 | 7 | ## Navigation 8 | 9 | ### Top Navigation Bar 10 | Back button - works like Chrome back button 11 | Forward button - works like Chrome forward button 12 | Refresh button - works like Chrome refresh button 13 | URL Input - works like Chrome URL input without the auto-suggestions 14 | 15 | ### Body 16 | Page content 17 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/core/StructTypeNode.js: -------------------------------------------------------------------------------- 1 | import Node, { addNodeClass } from './Node.js'; 2 | 3 | class StructTypeNode extends Node { 4 | 5 | constructor( types ) { 6 | 7 | super(); 8 | 9 | this.types = types; 10 | this.isStructTypeNode = true; 11 | 12 | } 13 | 14 | getMemberTypes() { 15 | 16 | return this.types; 17 | 18 | } 19 | 20 | } 21 | 22 | export default StructTypeNode; 23 | 24 | addNodeClass( 'StructTypeNode', StructTypeNode ); 25 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/core/NodeFunction.js: -------------------------------------------------------------------------------- 1 | class NodeFunction { 2 | 3 | constructor( type, inputs, name = '', presicion = '' ) { 4 | 5 | this.type = type; 6 | this.inputs = inputs; 7 | this.name = name; 8 | this.presicion = presicion; 9 | 10 | } 11 | 12 | getCode( /*name = this.name*/ ) { 13 | 14 | console.warn( 'Abstract function.' ); 15 | 16 | } 17 | 18 | } 19 | 20 | NodeFunction.isNodeFunction = true; 21 | 22 | export default NodeFunction; 23 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/functions/BSDF/EnvironmentBRDF.js: -------------------------------------------------------------------------------- 1 | import DFGApprox from './DFGApprox.js'; 2 | import { tslFn } from '../../shadernode/ShaderNode.js'; 3 | 4 | const EnvironmentBRDF = tslFn( ( inputs ) => { 5 | 6 | const { dotNV, specularColor, specularF90, roughness } = inputs; 7 | 8 | const fab = DFGApprox( { dotNV, roughness } ); 9 | return specularColor.mul( fab.x ).add( specularF90.mul( fab.y ) ); 10 | 11 | } ); 12 | 13 | export default EnvironmentBRDF; 14 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/functions/material/getGeometryRoughness.js: -------------------------------------------------------------------------------- 1 | import { normalGeometry } from '../../accessors/NormalNode.js'; 2 | import { tslFn } from '../../shadernode/ShaderNode.js'; 3 | 4 | const getGeometryRoughness = tslFn( () => { 5 | 6 | const dxy = normalGeometry.dFdx().abs().max( normalGeometry.dFdy().abs() ); 7 | const geometryRoughness = dxy.x.max( dxy.y ).max( dxy.z ); 8 | 9 | return geometryRoughness; 10 | 11 | } ); 12 | 13 | export default getGeometryRoughness; 14 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/shaders/BasicShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Simple test shader 3 | */ 4 | 5 | const BasicShader = { 6 | 7 | name: 'BasicShader', 8 | 9 | uniforms: {}, 10 | 11 | vertexShader: /* glsl */` 12 | 13 | void main() { 14 | 15 | gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 16 | 17 | }`, 18 | 19 | fragmentShader: /* glsl */` 20 | 21 | void main() { 22 | 23 | gl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 ); 24 | 25 | }` 26 | 27 | }; 28 | 29 | export { BasicShader }; 30 | -------------------------------------------------------------------------------- /apps/ptk/app/theme.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors": { 3 | "r": "#eb003b", 4 | "o": "#fa9614", 5 | "y": "#fadf16", 6 | "g": "#12e020", 7 | "c": "#12d9e0", 8 | "b": "#1283e0", 9 | "p": "#7c12e0", 10 | "m": "#f029bb" 11 | }, 12 | "base": [ 13 | "#000000", 14 | "#121117", 15 | "#312f3b", 16 | "#4a4759", 17 | "#646075", 18 | "#8b8899", 19 | "#b3b0c2", 20 | "#d6d5de", 21 | "#ffffff" 22 | ], 23 | "accent": "b" 24 | } -------------------------------------------------------------------------------- /src/assets/modules/three-addons/lights/IESSpotLight.js: -------------------------------------------------------------------------------- 1 | import { SpotLight } from 'three'; 2 | 3 | class IESSpotLight extends SpotLight { 4 | 5 | constructor( color, intensity, distance, angle, penumbra, decay ) { 6 | 7 | super( color, intensity, distance, angle, penumbra, decay ); 8 | 9 | this.iesMap = null; 10 | 11 | } 12 | 13 | copy( source, recursive ) { 14 | 15 | super.copy( source, recursive ); 16 | 17 | this.iesMap = source.iesMap; 18 | 19 | return this; 20 | 21 | } 22 | 23 | } 24 | 25 | export default IESSpotLight; 26 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/lines/Line2.js: -------------------------------------------------------------------------------- 1 | import { LineSegments2 } from '../lines/LineSegments2.js'; 2 | import { LineGeometry } from '../lines/LineGeometry.js'; 3 | import { LineMaterial } from '../lines/LineMaterial.js'; 4 | 5 | class Line2 extends LineSegments2 { 6 | 7 | constructor( geometry = new LineGeometry(), material = new LineMaterial( { color: Math.random() * 0xffffff } ) ) { 8 | 9 | super( geometry, material ); 10 | 11 | this.isLine2 = true; 12 | 13 | this.type = 'Line2'; 14 | 15 | } 16 | 17 | } 18 | 19 | export { Line2 }; 20 | -------------------------------------------------------------------------------- /src/sources/wpilog/source.js: -------------------------------------------------------------------------------- 1 | import * as util from "../../util.mjs"; 2 | import * as lib from "../../lib.mjs"; 3 | 4 | import HistoricalSource from "../historical-source.js"; 5 | 6 | 7 | export default class WPILOGSource extends HistoricalSource { 8 | static CLIENTDECODER = "./sources/wpilog/decoder-worker.js"; 9 | static CLIENTENCODER = "./sources/wpilog/encoder-worker.js"; 10 | static TYPE = "wpilog"; 11 | static WANTED = "uint8"; 12 | 13 | static getName() { return "WPILOG"; } 14 | 15 | constructor() { 16 | super(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/renderers/webgl-legacy/nodes/SlotNode.js: -------------------------------------------------------------------------------- 1 | import { Node } from '../../../nodes/Nodes.js'; 2 | 3 | class SlotNode extends Node { 4 | 5 | constructor( params ) { 6 | 7 | super( params.nodeType ); 8 | 9 | this.node = null; 10 | this.source = null; 11 | this.target = null; 12 | this.inclusionType = 'replace'; 13 | 14 | Object.assign( this, params ); 15 | 16 | } 17 | 18 | generate( builder ) { 19 | 20 | return this.node.build( builder, this.getNodeType( builder ) ); 21 | 22 | } 23 | 24 | } 25 | 26 | export default SlotNode; 27 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/lines/WireframeGeometry2.js: -------------------------------------------------------------------------------- 1 | import { 2 | WireframeGeometry 3 | } from 'three'; 4 | import { LineSegmentsGeometry } from '../lines/LineSegmentsGeometry.js'; 5 | 6 | class WireframeGeometry2 extends LineSegmentsGeometry { 7 | 8 | constructor( geometry ) { 9 | 10 | super(); 11 | 12 | this.isWireframeGeometry2 = true; 13 | 14 | this.type = 'WireframeGeometry2'; 15 | 16 | this.fromWireframeGeometry( new WireframeGeometry( geometry ) ); 17 | 18 | // set colors, maybe 19 | 20 | } 21 | 22 | } 23 | 24 | export { WireframeGeometry2 }; 25 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/core/ArrayUniformNode.js: -------------------------------------------------------------------------------- 1 | import UniformNode from './UniformNode.js'; 2 | import { addNodeClass } from './Node.js'; 3 | 4 | class ArrayUniformNode extends UniformNode { 5 | 6 | constructor( nodes = [] ) { 7 | 8 | super(); 9 | 10 | this.isArrayUniformNode = true; 11 | 12 | this.nodes = nodes; 13 | 14 | } 15 | 16 | getNodeType( builder ) { 17 | 18 | return this.nodes[ 0 ].getNodeType( builder ); 19 | 20 | } 21 | 22 | } 23 | 24 | export default ArrayUniformNode; 25 | 26 | addNodeClass( 'ArrayUniformNode', ArrayUniformNode ); 27 | -------------------------------------------------------------------------------- /src/planner/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 14 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/sources/csv/time/source.js: -------------------------------------------------------------------------------- 1 | import * as util from "../../../util.mjs"; 2 | import * as lib from "../../../lib.mjs"; 3 | 4 | import HistoricalSource from "../../historical-source.js"; 5 | 6 | 7 | export default class CSVTimeSource extends HistoricalSource { 8 | static CLIENTDECODER = "./sources/csv/time/decoder-worker.js"; 9 | static CLIENTENCODER = "./sources/csv/time/encoder-worker.js"; 10 | static TYPE = "csv-time"; 11 | static WANTED = "text"; 12 | 13 | static getName() { return "CSV-Time"; } 14 | 15 | constructor() { 16 | super(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/sources/csv/field/source.js: -------------------------------------------------------------------------------- 1 | import * as util from "../../../util.mjs"; 2 | import * as lib from "../../../lib.mjs"; 3 | 4 | import HistoricalSource from "../../historical-source.js"; 5 | 6 | 7 | export default class CSVFieldSource extends HistoricalSource { 8 | static CLIENTDECODER = "./sources/csv/field/decoder-worker.js"; 9 | static CLIENTENCODER = "./sources/csv/field/encoder-worker.js"; 10 | static TYPE = "csv-field"; 11 | static WANTED = "text"; 12 | 13 | static getName() { return "CSV-Field"; } 14 | 15 | constructor() { 16 | super(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/accessors/PointUVNode.js: -------------------------------------------------------------------------------- 1 | import Node, { addNodeClass } from '../core/Node.js'; 2 | import { nodeImmutable } from '../shadernode/ShaderNode.js'; 3 | 4 | class PointUVNode extends Node { 5 | 6 | constructor() { 7 | 8 | super( 'vec2' ); 9 | 10 | this.isPointUVNode = true; 11 | 12 | } 13 | 14 | generate( /*builder*/ ) { 15 | 16 | return 'vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )'; 17 | 18 | } 19 | 20 | } 21 | 22 | export default PointUVNode; 23 | 24 | export const pointUV = nodeImmutable( PointUVNode ); 25 | 26 | addNodeClass( 'PointUVNode', PointUVNode ); 27 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/lighting/AONode.js: -------------------------------------------------------------------------------- 1 | import LightingNode from './LightingNode.js'; 2 | import { addNodeClass } from '../core/Node.js'; 3 | 4 | class AONode extends LightingNode { 5 | 6 | constructor( aoNode = null ) { 7 | 8 | super(); 9 | 10 | this.aoNode = aoNode; 11 | 12 | } 13 | 14 | setup( builder ) { 15 | 16 | const aoIntensity = 1; 17 | const aoNode = this.aoNode.x.sub( 1.0 ).mul( aoIntensity ).add( 1.0 ); 18 | 19 | builder.context.ambientOcclusion.mulAssign( aoNode ); 20 | 21 | } 22 | 23 | } 24 | 25 | export default AONode; 26 | 27 | addNodeClass( 'AONode', AONode ); 28 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/objects/InstancedPoints.js: -------------------------------------------------------------------------------- 1 | import { 2 | Mesh 3 | } from 'three'; 4 | import InstancedPointsGeometry from '../geometries/InstancedPointsGeometry.js'; 5 | import InstancedPointsNodeMaterial from '../nodes/materials/InstancedPointsNodeMaterial.js'; 6 | 7 | class InstancedPoints extends Mesh { 8 | 9 | constructor( geometry = new InstancedPointsGeometry(), material = new InstancedPointsNodeMaterial() ) { 10 | 11 | super( geometry, material ); 12 | 13 | this.isInstancedPoints = true; 14 | 15 | this.type = 'InstancedPoints'; 16 | 17 | } 18 | 19 | } 20 | 21 | export default InstancedPoints; 22 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/renderers/common/Color4.js: -------------------------------------------------------------------------------- 1 | import { Color } from 'three'; 2 | 3 | class Color4 extends Color { 4 | 5 | constructor( r, g, b, a = 1 ) { 6 | 7 | super( r, g, b ); 8 | 9 | this.a = a; 10 | 11 | } 12 | 13 | set( r, g, b, a = 1 ) { 14 | 15 | this.a = a; 16 | 17 | return super.set( r, g, b ); 18 | 19 | } 20 | 21 | copy( color ) { 22 | 23 | if ( color.a !== undefined ) this.a = color.a; 24 | 25 | return super.copy( color ); 26 | 27 | } 28 | 29 | clone() { 30 | 31 | return new this.constructor( this.r, this.g, this.b, this.a ); 32 | 33 | } 34 | 35 | } 36 | 37 | export default Color4; 38 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/renderers/common/PostProcessing.js: -------------------------------------------------------------------------------- 1 | import { vec4, MeshBasicNodeMaterial } from '../../nodes/Nodes.js'; 2 | import QuadMesh from '../../objects/QuadMesh.js'; 3 | 4 | const quadMesh = new QuadMesh( new MeshBasicNodeMaterial() ); 5 | 6 | class PostProcessing { 7 | 8 | constructor( renderer, outputNode = vec4( 0, 0, 1, 1 ) ) { 9 | 10 | this.renderer = renderer; 11 | this.outputNode = outputNode; 12 | 13 | } 14 | 15 | render() { 16 | 17 | quadMesh.material.fragmentNode = this.outputNode; 18 | 19 | quadMesh.render( this.renderer ); 20 | 21 | } 22 | 23 | } 24 | 25 | export default PostProcessing; 26 | -------------------------------------------------------------------------------- /src/panel/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 14 | 19 | 20 | 21 |
22 |
23 |
24 | 25 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/functions/BSDF/Schlick_to_F0.js: -------------------------------------------------------------------------------- 1 | import { tslFn, vec3 } from '../../shadernode/ShaderNode.js'; 2 | 3 | const Schlick_to_F0 = tslFn( ( { f, f90, dotVH } ) => { 4 | 5 | const x = dotVH.oneMinus().saturate(); 6 | const x2 = x.mul( x ); 7 | const x5 = x.mul( x2, x2 ).clamp( 0, .9999 ); 8 | 9 | return f.sub( vec3( f90 ).mul( x5 ) ).div( x5.oneMinus() ); 10 | 11 | } ).setLayout( { 12 | name: 'Schlick_to_F0', 13 | type: 'vec3', 14 | inputs: [ 15 | { name: 'f', type: 'vec3' }, 16 | { name: 'f90', type: 'float' }, 17 | { name: 'dotVH', type: 'float' } 18 | ] 19 | } ); 20 | 21 | export default Schlick_to_F0; 22 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/functions/material/getRoughness.js: -------------------------------------------------------------------------------- 1 | import getGeometryRoughness from './getGeometryRoughness.js'; 2 | import { tslFn } from '../../shadernode/ShaderNode.js'; 3 | 4 | const getRoughness = tslFn( ( inputs ) => { 5 | 6 | const { roughness } = inputs; 7 | 8 | const geometryRoughness = getGeometryRoughness(); 9 | 10 | let roughnessFactor = roughness.max( 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap. 11 | roughnessFactor = roughnessFactor.add( geometryRoughness ); 12 | roughnessFactor = roughnessFactor.min( 1.0 ); 13 | 14 | return roughnessFactor; 15 | 16 | } ); 17 | 18 | export default getRoughness; 19 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/functions/BSDF/F_Schlick.js: -------------------------------------------------------------------------------- 1 | import { tslFn } from '../../shadernode/ShaderNode.js'; 2 | 3 | const F_Schlick = tslFn( ( { f0, f90, dotVH } ) => { 4 | 5 | // Original approximation by Christophe Schlick '94 6 | // float fresnel = pow( 1.0 - dotVH, 5.0 ); 7 | 8 | // Optimized variant (presented by Epic at SIGGRAPH '13) 9 | // https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf 10 | const fresnel = dotVH.mul( - 5.55473 ).sub( 6.98316 ).mul( dotVH ).exp2(); 11 | 12 | return f0.mul( fresnel.oneMinus() ).add( f90.mul( fresnel ) ); 13 | 14 | } ); // validated 15 | 16 | export default F_Schlick; 17 | -------------------------------------------------------------------------------- /src/assets/icons/merge.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/core/NodeUniform.js: -------------------------------------------------------------------------------- 1 | class NodeUniform { 2 | 3 | constructor( name, type, node, needsUpdate = undefined ) { 4 | 5 | this.isNodeUniform = true; 6 | 7 | this.name = name; 8 | this.type = type; 9 | this.node = node.getSelf(); 10 | this.needsUpdate = needsUpdate; 11 | 12 | } 13 | 14 | get value() { 15 | 16 | return this.node.value; 17 | 18 | } 19 | 20 | set value( val ) { 21 | 22 | this.node.value = val; 23 | 24 | } 25 | 26 | get id() { 27 | 28 | return this.node.id; 29 | 30 | } 31 | 32 | get groupNode() { 33 | 34 | return this.node.groupNode; 35 | 36 | } 37 | 38 | } 39 | 40 | export default NodeUniform; 41 | -------------------------------------------------------------------------------- /src/modal/style-modal.css: -------------------------------------------------------------------------------- 1 | #titlebar { 2 | display: none; 3 | } 4 | 5 | body { 6 | background-color: var(--v2); 7 | } 8 | 9 | #mount { 10 | top: 0px; 11 | 12 | height: 100%; 13 | max-height: 100%; 14 | 15 | background-color: transparent; 16 | 17 | -webkit-app-region: drag; 18 | } 19 | #PAGE { 20 | overflow: hidden; 21 | 22 | display: flex; 23 | flex-direction: column; 24 | flex-wrap: nowrap; 25 | justify-content: center; 26 | align-items: center; 27 | align-content: center; 28 | 29 | background-color: transparent; 30 | } 31 | 32 | ion-icon, .title, .content, .info, button { 33 | -webkit-app-region: no-drag; 34 | } 35 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/lighting/AmbientLightNode.js: -------------------------------------------------------------------------------- 1 | import AnalyticLightNode from './AnalyticLightNode.js'; 2 | import { addLightNode } from './LightsNode.js'; 3 | import { addNodeClass } from '../core/Node.js'; 4 | 5 | import { AmbientLight } from 'three'; 6 | 7 | class AmbientLightNode extends AnalyticLightNode { 8 | 9 | constructor( light = null ) { 10 | 11 | super( light ); 12 | 13 | } 14 | 15 | setup( { context } ) { 16 | 17 | context.irradiance.addAssign(this.colorNode ); 18 | 19 | } 20 | 21 | } 22 | 23 | export default AmbientLightNode; 24 | 25 | addNodeClass( 'AmbientLightNode', AmbientLightNode ); 26 | 27 | addLightNode( AmbientLight, AmbientLightNode ); 28 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/renderers/common/Buffer.js: -------------------------------------------------------------------------------- 1 | import Binding from './Binding.js'; 2 | import { getFloatLength } from './BufferUtils.js'; 3 | 4 | class Buffer extends Binding { 5 | 6 | constructor( name, buffer = null ) { 7 | 8 | super( name ); 9 | 10 | this.isBuffer = true; 11 | 12 | this.bytesPerElement = Float32Array.BYTES_PER_ELEMENT; 13 | 14 | this._buffer = buffer; 15 | 16 | } 17 | 18 | get byteLength() { 19 | 20 | return getFloatLength( this._buffer.byteLength ); 21 | 22 | } 23 | 24 | get buffer() { 25 | 26 | return this._buffer; 27 | 28 | } 29 | 30 | update() { 31 | 32 | return true; 33 | 34 | } 35 | 36 | } 37 | 38 | export default Buffer; 39 | -------------------------------------------------------------------------------- /apps/ptk/app/templates.json: -------------------------------------------------------------------------------- 1 | { 2 | "templates": { 3 | "2018": { 4 | "model": false, 5 | "size": [ 6 | 1646, 7 | 823 8 | ], 9 | "robotSize": 80, 10 | "robotMass": 75 11 | }, 12 | "2022": { 13 | "size": [ 14 | 1646, 15 | 823 16 | ], 17 | "robotSize": 80, 18 | "robotMass": 75 19 | }, 20 | "2023": { 21 | "size": [ 22 | 1654, 23 | 802 24 | ], 25 | "robotSize": 80, 26 | "robotMass": 75 27 | }, 28 | "2024": { 29 | "size": [ 30 | 1654, 31 | 821 32 | ], 33 | "robotSize": 84, 34 | "robotMass": 60, 35 | "options": { 36 | "free_percent": 1, 37 | "FOC": true 38 | } 39 | } 40 | }, 41 | "active": "2024" 42 | } -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/display/FrontFacingNode.js: -------------------------------------------------------------------------------- 1 | import Node, { addNodeClass } from '../core/Node.js'; 2 | import { nodeImmutable, float } from '../shadernode/ShaderNode.js'; 3 | 4 | class FrontFacingNode extends Node { 5 | 6 | constructor() { 7 | 8 | super( 'bool' ); 9 | 10 | this.isFrontFacingNode = true; 11 | 12 | } 13 | 14 | generate( builder ) { 15 | 16 | return builder.getFrontFacing(); 17 | 18 | } 19 | 20 | } 21 | 22 | export default FrontFacingNode; 23 | 24 | export const frontFacing = nodeImmutable( FrontFacingNode ); 25 | export const faceDirection = float( frontFacing ).mul( 2.0 ).sub( 1.0 ); 26 | 27 | addNodeClass( 'FrontFacingNode', FrontFacingNode ); 28 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/renderers/common/RenderLists.js: -------------------------------------------------------------------------------- 1 | import ChainMap from './ChainMap.js'; 2 | import RenderList from './RenderList.js'; 3 | 4 | class RenderLists { 5 | 6 | constructor() { 7 | 8 | this.lists = new ChainMap(); 9 | 10 | } 11 | 12 | get( scene, camera ) { 13 | 14 | const lists = this.lists; 15 | const keys = [ scene, camera ]; 16 | 17 | let list = lists.get( keys ); 18 | 19 | if ( list === undefined ) { 20 | 21 | list = new RenderList(); 22 | lists.set( keys, list ); 23 | 24 | } 25 | 26 | return list; 27 | 28 | } 29 | 30 | dispose() { 31 | 32 | this.lists = new ChainMap(); 33 | 34 | } 35 | 36 | } 37 | 38 | export default RenderLists; 39 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/renderers/webgl/utils/WebGLExtensions.js: -------------------------------------------------------------------------------- 1 | class WebGLExtensions { 2 | 3 | constructor( backend ) { 4 | 5 | this.backend = backend; 6 | 7 | this.gl = this.backend.gl; 8 | this.availableExtensions = this.gl.getSupportedExtensions(); 9 | 10 | this.extensions = {}; 11 | 12 | } 13 | 14 | get( name ) { 15 | 16 | let extension = this.extensions[ name ]; 17 | 18 | if ( extension === undefined ) { 19 | 20 | extension = this.gl.getExtension( name ); 21 | 22 | } 23 | 24 | return extension; 25 | 26 | } 27 | 28 | has( name ) { 29 | 30 | return this.availableExtensions.includes( name ); 31 | 32 | } 33 | 34 | } 35 | 36 | export default WebGLExtensions; 37 | -------------------------------------------------------------------------------- /src/panel/tabs/tooltab.js: -------------------------------------------------------------------------------- 1 | import * as util from "../../util.mjs"; 2 | import { V } from "../../util.mjs"; 3 | import * as lib from "../../lib.mjs"; 4 | 5 | import * as core from "../../core.mjs"; 6 | import { PROPERTYCACHE, GLOBALSTATE } from "../../core.mjs"; 7 | 8 | import * as app from "../../app.mjs"; 9 | 10 | 11 | import PanelTab from "./tab.js"; 12 | 13 | 14 | export default class PanelToolTab extends PanelTab { 15 | static NAME = "Tool"; 16 | static NICKNAME = "Tool"; 17 | static ICON = "build"; 18 | static ICONSRC = null; 19 | static ICONCOLOR = "var(--cp)"; 20 | 21 | constructor(a) { 22 | super(); 23 | 24 | this.elem.classList.add("tool"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/modal/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 14 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/materials/LineBasicNodeMaterial.js: -------------------------------------------------------------------------------- 1 | import NodeMaterial, { addNodeMaterial } from './NodeMaterial.js'; 2 | 3 | import { LineBasicMaterial } from 'three'; 4 | 5 | const defaultValues = new LineBasicMaterial(); 6 | 7 | class LineBasicNodeMaterial extends NodeMaterial { 8 | 9 | constructor( parameters ) { 10 | 11 | super(); 12 | 13 | this.isLineBasicNodeMaterial = true; 14 | 15 | this.lights = false; 16 | this.normals = false; 17 | 18 | this.setDefaultValues( defaultValues ); 19 | 20 | this.setValues( parameters ); 21 | 22 | } 23 | 24 | } 25 | 26 | export default LineBasicNodeMaterial; 27 | 28 | addNodeMaterial( 'LineBasicNodeMaterial', LineBasicNodeMaterial ); 29 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/accessors/TextureStoreNode.js: -------------------------------------------------------------------------------- 1 | import { addNodeClass } from '../core/Node.js'; 2 | import TextureNode from './TextureNode.js'; 3 | import { nodeProxy } from '../shadernode/ShaderNode.js'; 4 | 5 | class TextureStoreNode extends TextureNode { 6 | 7 | constructor( value, uvNode, storeNode = null ) { 8 | 9 | super( value, uvNode ); 10 | 11 | this.storeNode = storeNode; 12 | 13 | this.isStoreTextureNode = true; 14 | 15 | } 16 | 17 | getNodeType( /*builder*/ ) { 18 | 19 | return 'void'; 20 | 21 | } 22 | 23 | } 24 | 25 | export default TextureStoreNode; 26 | 27 | export const textureStore = nodeProxy( TextureStoreNode ); 28 | 29 | addNodeClass( 'TextureStoreNode', TextureStoreNode ); 30 | -------------------------------------------------------------------------------- /apps/ptk/app/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Peninsula Odometry2d Widget 6 | 7 | 8 | 9 | 17 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/accessors/InstancedPointsMaterialNode.js: -------------------------------------------------------------------------------- 1 | import MaterialNode from './MaterialNode.js'; 2 | import { addNodeClass } from '../core/Node.js'; 3 | import { nodeImmutable } from '../shadernode/ShaderNode.js'; 4 | 5 | class InstancedPointsMaterialNode extends MaterialNode { 6 | 7 | setup( /*builder*/ ) { 8 | 9 | return this.getFloat( this.scope ); 10 | 11 | } 12 | 13 | } 14 | 15 | InstancedPointsMaterialNode.POINT_WIDTH = 'pointWidth'; 16 | 17 | export default InstancedPointsMaterialNode; 18 | 19 | export const materialPointWidth = nodeImmutable( InstancedPointsMaterialNode, InstancedPointsMaterialNode.POINT_WIDTH ); 20 | 21 | addNodeClass( 'InstancedPointsMaterialNode', InstancedPointsMaterialNode ); 22 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/core/ConstNode.js: -------------------------------------------------------------------------------- 1 | import InputNode from './InputNode.js'; 2 | import { addNodeClass } from './Node.js'; 3 | 4 | class ConstNode extends InputNode { 5 | 6 | constructor( value, nodeType = null ) { 7 | 8 | super( value, nodeType ); 9 | 10 | this.isConstNode = true; 11 | 12 | } 13 | 14 | generateConst( builder ) { 15 | 16 | return builder.generateConst( this.getNodeType( builder ), this.value ); 17 | 18 | } 19 | 20 | generate( builder, output ) { 21 | 22 | const type = this.getNodeType( builder ); 23 | 24 | return builder.format( this.generateConst( builder ), type, output ); 25 | 26 | } 27 | 28 | } 29 | 30 | export default ConstNode; 31 | 32 | addNodeClass( 'ConstNode', ConstNode ); 33 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/core/ParameterNode.js: -------------------------------------------------------------------------------- 1 | import { addNodeClass } from './Node.js'; 2 | import { nodeObject } from '../shadernode/ShaderNode.js'; 3 | import PropertyNode from './PropertyNode.js'; 4 | 5 | class ParameterNode extends PropertyNode { 6 | 7 | constructor( nodeType, name = null ) { 8 | 9 | super( nodeType, name ); 10 | 11 | this.isParameterNode = true; 12 | 13 | } 14 | 15 | getHash() { 16 | 17 | return this.uuid; 18 | 19 | } 20 | 21 | generate() { 22 | 23 | return this.name; 24 | 25 | } 26 | 27 | } 28 | 29 | export default ParameterNode; 30 | 31 | export const parameter = ( type, name ) => nodeObject( new ParameterNode( type, name ) ); 32 | 33 | addNodeClass( 'ParameterNode', ParameterNode ); 34 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/materials/MeshBasicNodeMaterial.js: -------------------------------------------------------------------------------- 1 | import NodeMaterial, { addNodeMaterial } from './NodeMaterial.js'; 2 | 3 | import { MeshBasicMaterial } from 'three'; 4 | 5 | const defaultValues = new MeshBasicMaterial(); 6 | 7 | class MeshBasicNodeMaterial extends NodeMaterial { 8 | 9 | constructor( parameters ) { 10 | 11 | super(); 12 | 13 | this.isMeshBasicNodeMaterial = true; 14 | 15 | this.lights = false; 16 | //this.normals = false; @TODO: normals usage by context 17 | 18 | this.setDefaultValues( defaultValues ); 19 | 20 | this.setValues( parameters ); 21 | 22 | } 23 | 24 | } 25 | 26 | export default MeshBasicNodeMaterial; 27 | 28 | addNodeMaterial( 'MeshBasicNodeMaterial', MeshBasicNodeMaterial ); 29 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/lighting/LightUtils.js: -------------------------------------------------------------------------------- 1 | import { tslFn } from '../shadernode/ShaderNode.js'; 2 | 3 | export const getDistanceAttenuation = tslFn( ( inputs ) => { 4 | 5 | const { lightDistance, cutoffDistance, decayExponent } = inputs; 6 | 7 | // based upon Frostbite 3 Moving to Physically-based Rendering 8 | // page 32, equation 26: E[window1] 9 | // https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf 10 | const distanceFalloff = lightDistance.pow( decayExponent ).max( 0.01 ).reciprocal(); 11 | 12 | return cutoffDistance.greaterThan( 0 ).cond( 13 | distanceFalloff.mul( lightDistance.div( cutoffDistance ).pow4().oneMinus().clamp().pow2() ), 14 | distanceFalloff 15 | ); 16 | 17 | } ); // validated 18 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/accessors/StorageBufferNode.js: -------------------------------------------------------------------------------- 1 | import BufferNode from './BufferNode.js'; 2 | import { addNodeClass } from '../core/Node.js'; 3 | import { nodeObject } from '../shadernode/ShaderNode.js'; 4 | 5 | class StorageBufferNode extends BufferNode { 6 | 7 | constructor( value, bufferType, bufferCount = 0 ) { 8 | 9 | super( value, bufferType, bufferCount ); 10 | 11 | this.isStorageBufferNode = true; 12 | 13 | } 14 | 15 | getInputType( /*builder*/ ) { 16 | 17 | return 'storageBuffer'; 18 | 19 | } 20 | 21 | } 22 | 23 | export default StorageBufferNode; 24 | 25 | export const storage = ( value, type, count ) => nodeObject( new StorageBufferNode( value, type, count ) ); 26 | 27 | addNodeClass( 'StorageBufferNode', StorageBufferNode ); 28 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/core/constants.js: -------------------------------------------------------------------------------- 1 | export const NodeShaderStage = { 2 | VERTEX: 'vertex', 3 | FRAGMENT: 'fragment' 4 | }; 5 | 6 | export const NodeUpdateType = { 7 | NONE: 'none', 8 | FRAME: 'frame', 9 | RENDER: 'render', 10 | OBJECT: 'object' 11 | }; 12 | 13 | export const NodeType = { 14 | BOOLEAN: 'bool', 15 | INTEGER: 'int', 16 | FLOAT: 'float', 17 | VECTOR2: 'vec2', 18 | VECTOR3: 'vec3', 19 | VECTOR4: 'vec4', 20 | MATRIX3: 'mat3', 21 | MATRIX4: 'mat4' 22 | }; 23 | 24 | export const defaultShaderStages = [ 'fragment', 'vertex' ]; 25 | export const defaultBuildStages = [ 'setup', 'analyze', 'generate' ]; 26 | export const shaderStages = [ ...defaultShaderStages, 'compute' ]; 27 | export const vectorComponents = [ 'x', 'y', 'z', 'w' ]; 28 | -------------------------------------------------------------------------------- /src/assets/icons/jump.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 9 | 11 | 12 | -------------------------------------------------------------------------------- /src/assets/logo-part-solid.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/loaders/TIFFLoader.js: -------------------------------------------------------------------------------- 1 | import { 2 | DataTextureLoader, 3 | LinearFilter, 4 | LinearMipmapLinearFilter 5 | } from 'three'; 6 | 7 | import UTIF from '../libs/utif.module.js'; 8 | 9 | class TIFFLoader extends DataTextureLoader { 10 | 11 | constructor( manager ) { 12 | 13 | super( manager ); 14 | 15 | } 16 | 17 | parse( buffer ) { 18 | 19 | const ifds = UTIF.decode( buffer ); 20 | UTIF.decodeImage( buffer, ifds[ 0 ] ); 21 | const rgba = UTIF.toRGBA8( ifds[ 0 ] ); 22 | 23 | return { 24 | width: ifds[ 0 ].width, 25 | height: ifds[ 0 ].height, 26 | data: rgba, 27 | flipY: true, 28 | magFilter: LinearFilter, 29 | minFilter: LinearMipmapLinearFilter 30 | }; 31 | 32 | } 33 | 34 | } 35 | 36 | export { TIFFLoader }; 37 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/fog/FogNode.js: -------------------------------------------------------------------------------- 1 | import Node, { addNodeClass } from '../core/Node.js'; 2 | import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js'; 3 | 4 | class FogNode extends Node { 5 | 6 | constructor( colorNode, factorNode ) { 7 | 8 | super( 'float' ); 9 | 10 | this.isFogNode = true; 11 | 12 | this.colorNode = colorNode; 13 | this.factorNode = factorNode; 14 | 15 | } 16 | 17 | mixAssign( outputNode ) { 18 | 19 | return this.mix( outputNode, this.colorNode ); 20 | 21 | } 22 | 23 | setup() { 24 | 25 | return this.factorNode; 26 | 27 | } 28 | 29 | } 30 | 31 | export default FogNode; 32 | 33 | export const fog = nodeProxy( FogNode ); 34 | 35 | addNodeElement( 'fog', fog ); 36 | 37 | addNodeClass( 'FogNode', FogNode ); 38 | -------------------------------------------------------------------------------- /src/assets/icons/export.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/accessors/BufferNode.js: -------------------------------------------------------------------------------- 1 | import UniformNode from '../core/UniformNode.js'; 2 | import { addNodeClass } from '../core/Node.js'; 3 | import { nodeObject } from '../shadernode/ShaderNode.js'; 4 | 5 | class BufferNode extends UniformNode { 6 | 7 | constructor( value, bufferType, bufferCount = 0 ) { 8 | 9 | super( value, bufferType ); 10 | 11 | this.isBufferNode = true; 12 | 13 | this.bufferType = bufferType; 14 | this.bufferCount = bufferCount; 15 | 16 | } 17 | 18 | getInputType( /*builder*/ ) { 19 | 20 | return 'buffer'; 21 | 22 | } 23 | 24 | } 25 | 26 | export default BufferNode; 27 | 28 | export const buffer = ( value, type, count ) => nodeObject( new BufferNode( value, type, count ) ); 29 | 30 | addNodeClass( 'BufferNode', BufferNode ); 31 | -------------------------------------------------------------------------------- /docs/panel/tabs/TABLE.md: -------------------------------------------------------------------------------- 1 | ← Back 2 | 3 | # Table Tab 4 | 5 | Displays any value from source. Search timestamp or follow the current playback. Drag topics in to see them. 6 | 7 | ## Navigation 8 | 9 | ### Timestamp Navigator 10 | Displays timestamp that the table tab is locked to. If the follow toggle is on, then the table will automatically follow the log playback. Otherwise, the table will jump to the timestamp you input. 11 | 12 | ### Topics 13 | 14 | #### Header 15 | Hovering over the column header will show the full topic path. Clicking the x will remove the topic. These topics are draggable, and can be moved to a [Graph](../tabs/GRAPH.md), moved around within the Table, and even to other tabs. 16 | 17 | #### Column Data 18 | Shows the data within each topic. 19 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/functions/BSDF/D_GGX.js: -------------------------------------------------------------------------------- 1 | import { tslFn } from '../../shadernode/ShaderNode.js'; 2 | 3 | // Microfacet Models for Refraction through Rough Surfaces - equation (33) 4 | // http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html 5 | // alpha is "roughness squared" in Disney’s reparameterization 6 | const D_GGX = tslFn( ( { alpha, dotNH } ) => { 7 | 8 | const a2 = alpha.pow2(); 9 | 10 | const denom = dotNH.pow2().mul( a2.oneMinus() ).oneMinus(); // avoid alpha = 0 with dotNH = 1 11 | 12 | return a2.div( denom.pow2() ).mul( 1 / Math.PI ); 13 | 14 | } ).setLayout( { 15 | name: 'D_GGX', 16 | type: 'float', 17 | inputs: [ 18 | { name: 'alpha', type: 'float' }, 19 | { name: 'dotNH', type: 'float' } 20 | ] 21 | } ); // validated 22 | 23 | export default D_GGX; 24 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/renderers/common/DataMap.js: -------------------------------------------------------------------------------- 1 | class DataMap { 2 | 3 | constructor() { 4 | 5 | this.data = new WeakMap(); 6 | 7 | } 8 | 9 | get( object ) { 10 | 11 | let map = this.data.get( object ); 12 | 13 | if ( map === undefined ) { 14 | 15 | map = {}; 16 | this.data.set( object, map ); 17 | 18 | } 19 | 20 | return map; 21 | 22 | } 23 | 24 | delete( object ) { 25 | 26 | let map; 27 | 28 | if ( this.data.has( object ) ) { 29 | 30 | map = this.data.get( object ); 31 | 32 | this.data.delete( object ); 33 | 34 | } 35 | 36 | return map; 37 | 38 | } 39 | 40 | has( object ) { 41 | 42 | return this.data.has( object ); 43 | 44 | } 45 | 46 | dispose() { 47 | 48 | this.data.clear(); 49 | 50 | } 51 | 52 | } 53 | 54 | export default DataMap; 55 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/shaders/ExposureShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Exposure shader 3 | */ 4 | 5 | const ExposureShader = { 6 | 7 | name: 'ExposureShader', 8 | 9 | uniforms: { 10 | 11 | 'tDiffuse': { value: null }, 12 | 'exposure': { value: 1.0 } 13 | 14 | }, 15 | 16 | vertexShader: /* glsl */` 17 | 18 | varying vec2 vUv; 19 | 20 | void main() { 21 | 22 | vUv = uv; 23 | gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 24 | 25 | }`, 26 | 27 | fragmentShader: /* glsl */` 28 | 29 | uniform float exposure; 30 | 31 | uniform sampler2D tDiffuse; 32 | 33 | varying vec2 vUv; 34 | 35 | void main() { 36 | 37 | gl_FragColor = texture2D( tDiffuse, vUv ); 38 | gl_FragColor.rgb *= exposure; 39 | 40 | }` 41 | 42 | }; 43 | 44 | export { ExposureShader }; 45 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/display/PosterizeNode.js: -------------------------------------------------------------------------------- 1 | import TempNode from '../core/TempNode.js'; 2 | import { addNodeClass } from '../core/Node.js'; 3 | import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js'; 4 | 5 | class PosterizeNode extends TempNode { 6 | 7 | constructor( sourceNode, stepsNode ) { 8 | 9 | super(); 10 | 11 | this.sourceNode = sourceNode; 12 | this.stepsNode = stepsNode; 13 | 14 | } 15 | 16 | setup() { 17 | 18 | const { sourceNode, stepsNode } = this; 19 | 20 | return sourceNode.mul( stepsNode ).floor().div( stepsNode ); 21 | 22 | } 23 | 24 | } 25 | 26 | export default PosterizeNode; 27 | 28 | export const posterize = nodeProxy( PosterizeNode ); 29 | 30 | addNodeElement( 'posterize', posterize ); 31 | 32 | addNodeClass( 'PosterizeNode', PosterizeNode ); 33 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/shaders/CopyShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Full-screen textured quad shader 3 | */ 4 | 5 | const CopyShader = { 6 | 7 | name: 'CopyShader', 8 | 9 | uniforms: { 10 | 11 | 'tDiffuse': { value: null }, 12 | 'opacity': { value: 1.0 } 13 | 14 | }, 15 | 16 | vertexShader: /* glsl */` 17 | 18 | varying vec2 vUv; 19 | 20 | void main() { 21 | 22 | vUv = uv; 23 | gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 24 | 25 | }`, 26 | 27 | fragmentShader: /* glsl */` 28 | 29 | uniform float opacity; 30 | 31 | uniform sampler2D tDiffuse; 32 | 33 | varying vec2 vUv; 34 | 35 | void main() { 36 | 37 | vec4 texel = texture2D( tDiffuse, vUv ); 38 | gl_FragColor = opacity * texel; 39 | 40 | 41 | }` 42 | 43 | }; 44 | 45 | export { CopyShader }; 46 | -------------------------------------------------------------------------------- /src/planner/solver/constants.py: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | m = 67.5 #weight in kg cad 4 | l = 0.53 / 2 #side length in meters 5 | 6 | I = ((70979) * 1.829e-5) + ((2.811 * 10**5) * 1.829e-5) # from cCAD 7 | 8 | with open('data.in', 'r') as file: 9 | data = json.load(file) 10 | 11 | config = data['config'] 12 | 13 | l = config['side_length'] / 2 14 | m = config['mass'] 15 | I = config['moment_of_inertia'] 16 | 17 | free_speed_percent = config['free_percent'] 18 | 19 | pi = 3.1415 20 | pie = 3.142 21 | 22 | plot = True 23 | 24 | drive_gr = 1.0 / ((16.0 / 50) * (28.0 / 16) * (15.0 / 45)) 25 | 26 | motor_free_speed = 6000 #rpm 27 | 28 | if config['FOC']: 29 | motor_free_speed = 5800 30 | 31 | wheel_radius = 0.0504 #meters 32 | 33 | max_module_ground_speed = wheel_radius * 2 * pi * ((motor_free_speed / 60) / drive_gr) 34 | -------------------------------------------------------------------------------- /docs/panel/tabs/ADD.md: -------------------------------------------------------------------------------- 1 | ← Back 2 | 3 | # Add Tab 4 | 5 | Your main tab, where you can pick what tab to add. Includes searching for quick access to wanted tables, topics, and tools. 6 | 7 | ## Navigation 8 | 9 | ### Top Search Bar 10 | Type your search query, such as a topic or a table name, or a name of a tool. Clicking the x clears the search query. Sometimes, if you are searching a subsection of the available search topics, such as only tools, you must delete the entirety of your search query, then click delete again to exit out of searching within that subsection. 11 | 12 | Search filters include: 13 | - Tables only 14 | - Topics only 15 | - Tables and Topics only 16 | - Tools only 17 | 18 | Clicking on any of the search results will automatically replace this tab with the specified one. 19 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/accessors/UserDataNode.js: -------------------------------------------------------------------------------- 1 | import ReferenceNode from './ReferenceNode.js'; 2 | import { addNodeClass } from '../core/Node.js'; 3 | import { nodeObject } from '../shadernode/ShaderNode.js'; 4 | 5 | class UserDataNode extends ReferenceNode { 6 | 7 | constructor( property, inputType, userData = null ) { 8 | 9 | super( property, inputType, userData ); 10 | 11 | this.userData = userData; 12 | 13 | } 14 | 15 | update( frame ) { 16 | 17 | this.reference = this.userData !== null ? this.userData : frame.object.userData; 18 | 19 | super.update( frame ); 20 | 21 | } 22 | 23 | } 24 | 25 | export default UserDataNode; 26 | 27 | export const userData = ( name, inputType, userData ) => nodeObject( new UserDataNode( name, inputType, userData ) ); 28 | 29 | addNodeClass( 'UserDataNode', UserDataNode ); 30 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/shaders/GammaCorrectionShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Gamma Correction Shader 3 | * http://en.wikipedia.org/wiki/gamma_correction 4 | */ 5 | 6 | const GammaCorrectionShader = { 7 | 8 | name: 'GammaCorrectionShader', 9 | 10 | uniforms: { 11 | 12 | 'tDiffuse': { value: null } 13 | 14 | }, 15 | 16 | vertexShader: /* glsl */` 17 | 18 | varying vec2 vUv; 19 | 20 | void main() { 21 | 22 | vUv = uv; 23 | gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 24 | 25 | }`, 26 | 27 | fragmentShader: /* glsl */` 28 | 29 | uniform sampler2D tDiffuse; 30 | 31 | varying vec2 vUv; 32 | 33 | void main() { 34 | 35 | vec4 tex = texture2D( tDiffuse, vUv ); 36 | 37 | gl_FragColor = sRGBTransferOETF( tex ); 38 | 39 | }` 40 | 41 | }; 42 | 43 | export { GammaCorrectionShader }; 44 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/renderers/webgl/utils/WebGLCapabilities.js: -------------------------------------------------------------------------------- 1 | class WebGLCapabilities { 2 | 3 | constructor( backend ) { 4 | 5 | this.backend = backend; 6 | 7 | this.maxAnisotropy = null; 8 | 9 | } 10 | 11 | getMaxAnisotropy() { 12 | 13 | if ( this.maxAnisotropy !== null ) return this.maxAnisotropy; 14 | 15 | const gl = this.backend.gl; 16 | const extensions = this.backend.extensions; 17 | 18 | if ( extensions.has( 'EXT_texture_filter_anisotropic' ) === true ) { 19 | 20 | const extension = extensions.get( 'EXT_texture_filter_anisotropic' ); 21 | 22 | this.maxAnisotropy = gl.getParameter( extension.MAX_TEXTURE_MAX_ANISOTROPY_EXT ); 23 | 24 | } else { 25 | 26 | this.maxAnisotropy = 0; 27 | 28 | } 29 | 30 | return this.maxAnisotropy; 31 | 32 | } 33 | 34 | } 35 | 36 | export default WebGLCapabilities; 37 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/utils/ArrayElementNode.js: -------------------------------------------------------------------------------- 1 | import Node, { addNodeClass } from '../core/Node.js'; 2 | 3 | class ArrayElementNode extends Node { // @TODO: If extending from TempNode it breaks webgpu_compute 4 | 5 | constructor( node, indexNode ) { 6 | 7 | super(); 8 | 9 | this.node = node; 10 | this.indexNode = indexNode; 11 | 12 | this.isArrayElementNode = true; 13 | 14 | } 15 | 16 | getNodeType( builder ) { 17 | 18 | return this.node.getNodeType( builder ); 19 | 20 | } 21 | 22 | generate( builder ) { 23 | 24 | const nodeSnippet = this.node.build( builder ); 25 | const indexSnippet = this.indexNode.build( builder, 'uint' ); 26 | 27 | return `${nodeSnippet}[ ${indexSnippet} ]`; 28 | 29 | } 30 | 31 | } 32 | 33 | export default ArrayElementNode; 34 | 35 | addNodeClass( 'ArrayElementNode', ArrayElementNode ); 36 | -------------------------------------------------------------------------------- /src/assets/icons/array.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 10 | 13 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/renderers/common/nodes/NodeUniformsGroup.js: -------------------------------------------------------------------------------- 1 | import UniformsGroup from '../UniformsGroup.js'; 2 | 3 | let id = 0; 4 | 5 | class NodeUniformsGroup extends UniformsGroup { 6 | 7 | constructor( name, groupNode ) { 8 | 9 | super( name ); 10 | 11 | this.id = id ++; 12 | this.groupNode = groupNode; 13 | 14 | this.isNodeUniformsGroup = true; 15 | 16 | } 17 | 18 | get shared() { 19 | 20 | return this.groupNode.shared; 21 | 22 | } 23 | 24 | getNodes() { 25 | 26 | const nodes = []; 27 | 28 | for ( const uniform of this.uniforms ) { 29 | 30 | const node = uniform.nodeUniform.node; 31 | 32 | if ( ! node ) throw new Error( 'NodeUniformsGroup: Uniform has no node.' ); 33 | 34 | nodes.push( node ); 35 | 36 | } 37 | 38 | return nodes; 39 | 40 | } 41 | 42 | } 43 | 44 | export default NodeUniformsGroup; 45 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/code/ExpressionNode.js: -------------------------------------------------------------------------------- 1 | import Node, { addNodeClass } from '../core/Node.js'; 2 | import { nodeProxy } from '../shadernode/ShaderNode.js'; 3 | 4 | class ExpressionNode extends Node { 5 | 6 | constructor( snippet = '', nodeType = 'void' ) { 7 | 8 | super( nodeType ); 9 | 10 | this.snippet = snippet; 11 | 12 | } 13 | 14 | generate( builder, output ) { 15 | 16 | const type = this.getNodeType( builder ); 17 | const snippet = this.snippet; 18 | 19 | if ( type === 'void' ) { 20 | 21 | builder.addLineFlowCode( snippet ); 22 | 23 | } else { 24 | 25 | return builder.format( `( ${ snippet } )`, type, output ); 26 | 27 | } 28 | 29 | } 30 | 31 | } 32 | 33 | export default ExpressionNode; 34 | 35 | export const expression = nodeProxy( ExpressionNode ); 36 | 37 | addNodeClass( 'ExpressionNode', ExpressionNode ); 38 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/renderers/common/BufferUtils.js: -------------------------------------------------------------------------------- 1 | import { GPU_CHUNK_BYTES } from './Constants.js'; 2 | 3 | function getFloatLength( floatLength ) { 4 | 5 | // ensure chunk size alignment (STD140 layout) 6 | 7 | return floatLength + ( ( GPU_CHUNK_BYTES - ( floatLength % GPU_CHUNK_BYTES ) ) % GPU_CHUNK_BYTES ); 8 | 9 | } 10 | 11 | function getVectorLength( count, vectorLength = 4 ) { 12 | 13 | const strideLength = getStrideLength( vectorLength ); 14 | 15 | const floatLength = strideLength * count; 16 | 17 | return getFloatLength( floatLength ); 18 | 19 | } 20 | 21 | function getStrideLength( vectorLength ) { 22 | 23 | const strideLength = 4; 24 | 25 | return vectorLength + ( ( strideLength - ( vectorLength % strideLength ) ) % strideLength ); 26 | 27 | } 28 | 29 | export { 30 | getFloatLength, 31 | getVectorLength, 32 | getStrideLength 33 | }; 34 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/materials/PointsNodeMaterial.js: -------------------------------------------------------------------------------- 1 | import NodeMaterial, { addNodeMaterial } from './NodeMaterial.js'; 2 | 3 | import { PointsMaterial } from 'three'; 4 | 5 | const defaultValues = new PointsMaterial(); 6 | 7 | class PointsNodeMaterial extends NodeMaterial { 8 | 9 | constructor( parameters ) { 10 | 11 | super(); 12 | 13 | this.isPointsNodeMaterial = true; 14 | 15 | this.lights = false; 16 | this.normals = false; 17 | this.transparent = true; 18 | 19 | this.sizeNode = null; 20 | 21 | this.setDefaultValues( defaultValues ); 22 | 23 | this.setValues( parameters ); 24 | 25 | } 26 | 27 | copy( source ) { 28 | 29 | this.sizeNode = source.sizeNode; 30 | 31 | return super.copy( source ); 32 | 33 | } 34 | 35 | } 36 | 37 | export default PointsNodeMaterial; 38 | 39 | addNodeMaterial( 'PointsNodeMaterial', PointsNodeMaterial ); 40 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/offscreen/jank.js: -------------------------------------------------------------------------------- 1 | let interval = null; 2 | let result = null; 3 | 4 | function initJank() { 5 | 6 | const button = document.getElementById( 'button' ); 7 | button.addEventListener( 'click', function () { 8 | 9 | if ( interval === null ) { 10 | 11 | interval = setInterval( jank, 1000 / 60 ); 12 | 13 | button.textContent = 'STOP JANK'; 14 | 15 | } else { 16 | 17 | clearInterval( interval ); 18 | interval = null; 19 | 20 | button.textContent = 'START JANK'; 21 | result.textContent = ''; 22 | 23 | } 24 | 25 | } ); 26 | 27 | result = document.getElementById( 'result' ); 28 | 29 | } 30 | 31 | function jank() { 32 | 33 | let number = 0; 34 | 35 | for ( let i = 0; i < 10000000; i ++ ) { 36 | 37 | number += Math.random(); 38 | 39 | } 40 | 41 | result.textContent = number; 42 | 43 | } 44 | 45 | export default initJank; 46 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/renderers/common/Animation.js: -------------------------------------------------------------------------------- 1 | class Animation { 2 | 3 | constructor( nodes, info ) { 4 | 5 | this.nodes = nodes; 6 | this.info = info; 7 | 8 | this.animationLoop = null; 9 | this.requestId = null; 10 | 11 | this._init(); 12 | 13 | } 14 | 15 | _init() { 16 | 17 | const update = ( time, frame ) => { 18 | 19 | this.requestId = self.requestAnimationFrame( update ); 20 | 21 | this.nodes.nodeFrame.update(); 22 | 23 | this.info.frame = this.nodes.nodeFrame.frameId; 24 | 25 | if ( this.animationLoop !== null ) this.animationLoop( time, frame ); 26 | 27 | }; 28 | 29 | update(); 30 | 31 | } 32 | 33 | dispose() { 34 | 35 | self.cancelAnimationFrame( this.requestId ); 36 | 37 | } 38 | 39 | setAnimationLoop( callback ) { 40 | 41 | this.animationLoop = callback; 42 | 43 | } 44 | 45 | } 46 | 47 | export default Animation; 48 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/shaders/LuminosityShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Luminosity 3 | * http://en.wikipedia.org/wiki/Luminosity 4 | */ 5 | 6 | const LuminosityShader = { 7 | 8 | name: 'LuminosityShader', 9 | 10 | uniforms: { 11 | 12 | 'tDiffuse': { value: null } 13 | 14 | }, 15 | 16 | vertexShader: /* glsl */` 17 | 18 | varying vec2 vUv; 19 | 20 | void main() { 21 | 22 | vUv = uv; 23 | 24 | gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 25 | 26 | }`, 27 | 28 | fragmentShader: /* glsl */` 29 | 30 | #include 31 | 32 | uniform sampler2D tDiffuse; 33 | 34 | varying vec2 vUv; 35 | 36 | void main() { 37 | 38 | vec4 texel = texture2D( tDiffuse, vUv ); 39 | 40 | float l = luminance( texel.rgb ); 41 | 42 | gl_FragColor = vec4( l, l, l, texel.w ); 43 | 44 | }` 45 | 46 | }; 47 | 48 | export { LuminosityShader }; 49 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/utils/DiscardNode.js: -------------------------------------------------------------------------------- 1 | import CondNode from '../math/CondNode.js'; 2 | import { expression } from '../code/ExpressionNode.js'; 3 | import { addNodeClass } from '../core/Node.js'; 4 | import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js'; 5 | 6 | let discardExpression; 7 | 8 | class DiscardNode extends CondNode { 9 | 10 | constructor( condNode ) { 11 | 12 | discardExpression = discardExpression || expression( 'discard' ); 13 | 14 | super( condNode, discardExpression ); 15 | 16 | } 17 | 18 | } 19 | 20 | export default DiscardNode; 21 | 22 | export const inlineDiscard = nodeProxy( DiscardNode ); 23 | export const discard = ( condNode ) => inlineDiscard( condNode ).append(); 24 | 25 | addNodeElement( 'discard', discard ); // @TODO: Check... this cause a little confusing using in chaining 26 | 27 | addNodeClass( 'DiscardNode', DiscardNode ); 28 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/renderers/common/RenderContext.js: -------------------------------------------------------------------------------- 1 | import { Vector4 } from 'three'; 2 | 3 | let id = 0; 4 | 5 | class RenderContext { 6 | 7 | constructor() { 8 | 9 | this.id = id ++; 10 | 11 | this.color = true; 12 | this.clearColor = true; 13 | this.clearColorValue = { r: 0, g: 0, b: 0, a: 1 }; 14 | 15 | this.depth = true; 16 | this.clearDepth = true; 17 | this.clearDepthValue = 1; 18 | 19 | this.stencil = true; 20 | this.clearStencil = true; 21 | this.clearStencilValue = 1; 22 | 23 | this.viewport = false; 24 | this.viewportValue = new Vector4(); 25 | 26 | this.scissor = false; 27 | this.scissorValue = new Vector4(); 28 | 29 | this.textures = null; 30 | this.depthTexture = null; 31 | this.activeCubeFace = 0; 32 | this.sampleCount = 1; 33 | 34 | this.width = 0; 35 | this.height = 0; 36 | 37 | } 38 | 39 | } 40 | 41 | export default RenderContext; 42 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/materials/MeshLambertNodeMaterial.js: -------------------------------------------------------------------------------- 1 | import NodeMaterial, { addNodeMaterial } from './NodeMaterial.js'; 2 | import PhongLightingModel from '../functions/PhongLightingModel.js'; 3 | 4 | import { MeshLambertMaterial } from 'three'; 5 | 6 | const defaultValues = new MeshLambertMaterial(); 7 | 8 | class MeshLambertNodeMaterial extends NodeMaterial { 9 | 10 | constructor( parameters ) { 11 | 12 | super(); 13 | 14 | this.isMeshLambertNodeMaterial = true; 15 | 16 | this.lights = true; 17 | 18 | this.setDefaultValues( defaultValues ); 19 | 20 | this.setValues( parameters ); 21 | 22 | } 23 | 24 | setupLightingModel( /*builder*/ ) { 25 | 26 | return new PhongLightingModel( false ); // ( specular ) -> force lambert 27 | 28 | } 29 | 30 | } 31 | 32 | export default MeshLambertNodeMaterial; 33 | 34 | addNodeMaterial( 'MeshLambertNodeMaterial', MeshLambertNodeMaterial ); 35 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/math/ColorConverter.js: -------------------------------------------------------------------------------- 1 | import { MathUtils } from 'three'; 2 | 3 | const _hsl = {}; 4 | 5 | class ColorConverter { 6 | 7 | static setHSV( color, h, s, v ) { 8 | 9 | // https://gist.github.com/xpansive/1337890#file-index-js 10 | 11 | h = MathUtils.euclideanModulo( h, 1 ); 12 | s = MathUtils.clamp( s, 0, 1 ); 13 | v = MathUtils.clamp( v, 0, 1 ); 14 | 15 | return color.setHSL( h, ( s * v ) / ( ( h = ( 2 - s ) * v ) < 1 ? h : ( 2 - h ) ), h * 0.5 ); 16 | 17 | } 18 | 19 | static getHSV( color, target ) { 20 | 21 | color.getHSL( _hsl ); 22 | 23 | // based on https://gist.github.com/xpansive/1337890#file-index-js 24 | _hsl.s *= ( _hsl.l < 0.5 ) ? _hsl.l : ( 1 - _hsl.l ); 25 | 26 | target.h = _hsl.h; 27 | target.s = 2 * _hsl.s / ( _hsl.l + _hsl.s ); 28 | target.v = _hsl.l + _hsl.s; 29 | 30 | return target; 31 | 32 | } 33 | 34 | } 35 | 36 | export { ColorConverter }; 37 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/fog/FogRangeNode.js: -------------------------------------------------------------------------------- 1 | import FogNode from './FogNode.js'; 2 | import { smoothstep } from '../math/MathNode.js'; 3 | import { positionView } from '../accessors/PositionNode.js'; 4 | import { addNodeClass } from '../core/Node.js'; 5 | import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js'; 6 | 7 | class FogRangeNode extends FogNode { 8 | 9 | constructor( colorNode, nearNode, farNode ) { 10 | 11 | super( colorNode ); 12 | 13 | this.isFogRangeNode = true; 14 | 15 | this.nearNode = nearNode; 16 | this.farNode = farNode; 17 | 18 | } 19 | 20 | setup() { 21 | 22 | return smoothstep( this.nearNode, this.farNode, positionView.z.negate() ); 23 | 24 | } 25 | 26 | } 27 | 28 | export default FogRangeNode; 29 | 30 | export const rangeFog = nodeProxy( FogRangeNode ); 31 | 32 | addNodeElement( 'rangeFog', rangeFog ); 33 | 34 | addNodeClass( 'FogRangeNode', FogRangeNode ); 35 | -------------------------------------------------------------------------------- /src/assets/logo-part-2.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/fog/FogExp2Node.js: -------------------------------------------------------------------------------- 1 | import FogNode from './FogNode.js'; 2 | import { positionView } from '../accessors/PositionNode.js'; 3 | import { addNodeClass } from '../core/Node.js'; 4 | import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js'; 5 | 6 | class FogExp2Node extends FogNode { 7 | 8 | constructor( colorNode, densityNode ) { 9 | 10 | super( colorNode ); 11 | 12 | this.isFogExp2Node = true; 13 | 14 | this.densityNode = densityNode; 15 | 16 | } 17 | 18 | setup() { 19 | 20 | const depthNode = positionView.z.negate(); 21 | const densityNode = this.densityNode; 22 | 23 | return densityNode.mul( densityNode, depthNode, depthNode ).negate().exp().oneMinus(); 24 | 25 | } 26 | 27 | } 28 | 29 | export default FogExp2Node; 30 | 31 | export const densityFog = nodeProxy( FogExp2Node ); 32 | 33 | addNodeElement( 'densityFog', densityFog ); 34 | 35 | addNodeClass( 'FogExp2Node', FogExp2Node ); 36 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/utils/MatcapUVNode.js: -------------------------------------------------------------------------------- 1 | import TempNode from '../core/TempNode.js'; 2 | import { transformedNormalView } from '../accessors/NormalNode.js'; 3 | import { positionViewDirection } from '../accessors/PositionNode.js'; 4 | import { nodeImmutable, vec2, vec3 } from '../shadernode/ShaderNode.js'; 5 | import { addNodeClass } from '../core/Node.js'; 6 | 7 | class MatcapUVNode extends TempNode { 8 | 9 | constructor() { 10 | 11 | super( 'vec2' ); 12 | 13 | } 14 | 15 | setup() { 16 | 17 | const x = vec3( positionViewDirection.z, 0, positionViewDirection.x.negate() ).normalize(); 18 | const y = positionViewDirection.cross( x ); 19 | 20 | return vec2( x.dot( transformedNormalView ), y.dot( transformedNormalView ) ).mul( 0.495 ).add( 0.5 ); 21 | 22 | } 23 | 24 | } 25 | 26 | export default MatcapUVNode; 27 | 28 | export const matcapUV = nodeImmutable( MatcapUVNode ); 29 | 30 | addNodeClass( 'MatcapUVNode', MatcapUVNode ); 31 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/accessors/ReflectVectorNode.js: -------------------------------------------------------------------------------- 1 | import Node, { addNodeClass } from '../core/Node.js'; 2 | import { cameraViewMatrix } from './CameraNode.js'; 3 | import { transformedNormalView } from './NormalNode.js'; 4 | import { positionViewDirection } from './PositionNode.js'; 5 | import { nodeImmutable } from '../shadernode/ShaderNode.js'; 6 | 7 | class ReflectVectorNode extends Node { 8 | 9 | constructor() { 10 | 11 | super( 'vec3' ); 12 | 13 | } 14 | 15 | getHash( /*builder*/ ) { 16 | 17 | return 'reflectVector'; 18 | 19 | } 20 | 21 | setup() { 22 | 23 | const reflectView = positionViewDirection.negate().reflect( transformedNormalView ); 24 | 25 | return reflectView.transformDirection( cameraViewMatrix ); 26 | 27 | } 28 | 29 | } 30 | 31 | export default ReflectVectorNode; 32 | 33 | export const reflectVector = nodeImmutable( ReflectVectorNode ); 34 | 35 | addNodeClass( 'ReflectVectorNode', ReflectVectorNode ); 36 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/core/UniformGroupNode.js: -------------------------------------------------------------------------------- 1 | import Node from './Node.js'; 2 | import { addNodeClass } from './Node.js'; 3 | 4 | class UniformGroupNode extends Node { 5 | 6 | constructor( name, shared = false ) { 7 | 8 | super( 'string' ); 9 | 10 | this.name = name; 11 | this.version = 0; 12 | 13 | this.shared = shared; 14 | 15 | this.isUniformGroup = true; 16 | 17 | } 18 | 19 | set needsUpdate( value ) { 20 | 21 | if ( value === true ) this.version ++; 22 | 23 | } 24 | 25 | } 26 | 27 | export const uniformGroup = ( name ) => new UniformGroupNode( name ); 28 | export const sharedUniformGroup = ( name ) => new UniformGroupNode( name, true ); 29 | 30 | export const frameGroup = sharedUniformGroup( 'frame' ); 31 | export const renderGroup = sharedUniformGroup( 'render' ); 32 | export const objectGroup = uniformGroup( 'object' ); 33 | 34 | export default UniformGroupNode; 35 | 36 | addNodeClass( 'UniformGroupNode', UniformGroupNode ); 37 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/shaders/UnpackDepthRGBAShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Unpack RGBA depth shader 3 | * - show RGBA encoded depth as monochrome color 4 | */ 5 | 6 | const UnpackDepthRGBAShader = { 7 | 8 | name: 'UnpackDepthRGBAShader', 9 | 10 | uniforms: { 11 | 12 | 'tDiffuse': { value: null }, 13 | 'opacity': { value: 1.0 } 14 | 15 | }, 16 | 17 | vertexShader: /* glsl */` 18 | 19 | varying vec2 vUv; 20 | 21 | void main() { 22 | 23 | vUv = uv; 24 | gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 25 | 26 | }`, 27 | 28 | fragmentShader: /* glsl */` 29 | 30 | uniform float opacity; 31 | 32 | uniform sampler2D tDiffuse; 33 | 34 | varying vec2 vUv; 35 | 36 | #include 37 | 38 | void main() { 39 | 40 | float depth = 1.0 - unpackRGBAToDepth( texture2D( tDiffuse, vUv ) ); 41 | gl_FragColor = vec4( vec3( depth ), opacity ); 42 | 43 | }` 44 | 45 | }; 46 | 47 | export { UnpackDepthRGBAShader }; 48 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/accessors/UVNode.js: -------------------------------------------------------------------------------- 1 | import { addNodeClass } from '../core/Node.js'; 2 | import AttributeNode from '../core/AttributeNode.js'; 3 | import { nodeObject } from '../shadernode/ShaderNode.js'; 4 | 5 | class UVNode extends AttributeNode { 6 | 7 | constructor( index = 0 ) { 8 | 9 | super( null, 'vec2' ); 10 | 11 | this.isUVNode = true; 12 | 13 | this.index = index; 14 | 15 | } 16 | 17 | getAttributeName( /*builder*/ ) { 18 | 19 | const index = this.index; 20 | 21 | return 'uv' + ( index > 0 ? index : '' ); 22 | 23 | } 24 | 25 | serialize( data ) { 26 | 27 | super.serialize( data ); 28 | 29 | data.index = this.index; 30 | 31 | } 32 | 33 | deserialize( data ) { 34 | 35 | super.deserialize( data ); 36 | 37 | this.index = data.index; 38 | 39 | } 40 | 41 | } 42 | 43 | export default UVNode; 44 | 45 | export const uv = ( ...params ) => nodeObject( new UVNode( ...params ) ); 46 | 47 | addNodeClass( 'UVNode', UVNode ); 48 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/shaders/ColorifyShader.js: -------------------------------------------------------------------------------- 1 | import { 2 | Color 3 | } from 'three'; 4 | 5 | /** 6 | * Colorify shader 7 | */ 8 | 9 | const ColorifyShader = { 10 | 11 | name: 'ColorifyShader', 12 | 13 | uniforms: { 14 | 15 | 'tDiffuse': { value: null }, 16 | 'color': { value: new Color( 0xffffff ) } 17 | 18 | }, 19 | 20 | vertexShader: /* glsl */` 21 | 22 | varying vec2 vUv; 23 | 24 | void main() { 25 | 26 | vUv = uv; 27 | gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 28 | 29 | }`, 30 | 31 | fragmentShader: /* glsl */` 32 | 33 | uniform vec3 color; 34 | uniform sampler2D tDiffuse; 35 | 36 | varying vec2 vUv; 37 | 38 | void main() { 39 | 40 | vec4 texel = texture2D( tDiffuse, vUv ); 41 | 42 | vec3 luma = vec3( 0.299, 0.587, 0.114 ); 43 | float v = dot( texel.xyz, luma ); 44 | 45 | gl_FragColor = vec4( v * color, texel.w ); 46 | 47 | }` 48 | 49 | }; 50 | 51 | export { ColorifyShader }; 52 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/math/HashNode.js: -------------------------------------------------------------------------------- 1 | import Node, { addNodeClass } from '../core/Node.js'; 2 | import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js'; 3 | 4 | class HashNode extends Node { 5 | 6 | constructor( seedNode ) { 7 | 8 | super(); 9 | 10 | this.seedNode = seedNode; 11 | 12 | } 13 | 14 | setup( /*builder*/ ) { 15 | 16 | // Taken from https://www.shadertoy.com/view/XlGcRh, originally from pcg-random.org 17 | 18 | const state = this.seedNode.uint().mul( 747796405 ).add( 2891336453 ); 19 | const word = state.shiftRight( state.shiftRight( 28 ).add( 4 ) ).bitXor( state ).mul( 277803737 ); 20 | const result = word.shiftRight( 22 ).bitXor( word ); 21 | 22 | return result.float().mul( 1 / 2 ** 32 ); // Convert to range [0, 1) 23 | 24 | } 25 | 26 | } 27 | 28 | export default HashNode; 29 | 30 | export const hash = nodeProxy( HashNode ); 31 | 32 | addNodeElement( 'hash', hash ); 33 | 34 | addNodeClass( 'HashNode', HashNode ); 35 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/core/BypassNode.js: -------------------------------------------------------------------------------- 1 | import Node, { addNodeClass } from './Node.js'; 2 | import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js'; 3 | 4 | class BypassNode extends Node { 5 | 6 | constructor( returnNode, callNode ) { 7 | 8 | super(); 9 | 10 | this.isBypassNode = true; 11 | 12 | this.outputNode = returnNode; 13 | this.callNode = callNode; 14 | 15 | } 16 | 17 | getNodeType( builder ) { 18 | 19 | return this.outputNode.getNodeType( builder ); 20 | 21 | } 22 | 23 | generate( builder ) { 24 | 25 | const snippet = this.callNode.build( builder, 'void' ); 26 | 27 | if ( snippet !== '' ) { 28 | 29 | builder.addLineFlowCode( snippet ); 30 | 31 | } 32 | 33 | return this.outputNode.build( builder ); 34 | 35 | } 36 | 37 | } 38 | 39 | export default BypassNode; 40 | 41 | export const bypass = nodeProxy( BypassNode ); 42 | 43 | addNodeElement( 'bypass', bypass ); 44 | 45 | addNodeClass( 'BypassNode', BypassNode ); 46 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/utils/EquirectUVNode.js: -------------------------------------------------------------------------------- 1 | import TempNode from '../core/TempNode.js'; 2 | import { positionWorldDirection } from '../accessors/PositionNode.js'; 3 | import { nodeProxy, vec2 } from '../shadernode/ShaderNode.js'; 4 | import { addNodeClass } from '../core/Node.js'; 5 | 6 | class EquirectUVNode extends TempNode { 7 | 8 | constructor( dirNode = positionWorldDirection ) { 9 | 10 | super( 'vec2' ); 11 | 12 | this.dirNode = dirNode; 13 | 14 | } 15 | 16 | setup() { 17 | 18 | const dir = this.dirNode; 19 | 20 | const u = dir.z.atan2( dir.x ).mul( 1 / ( Math.PI * 2 ) ).add( 0.5 ); 21 | const v = dir.y.negate().clamp( - 1.0, 1.0 ).asin().mul( 1 / Math.PI ).add( 0.5 ); // @TODO: The use of negate() here could be an NDC issue. 22 | 23 | return vec2( u, v ); 24 | 25 | } 26 | 27 | } 28 | 29 | export default EquirectUVNode; 30 | 31 | export const equirectUV = nodeProxy( EquirectUVNode ); 32 | 33 | addNodeClass( 'EquirectUVNode', EquirectUVNode ); 34 | -------------------------------------------------------------------------------- /src/assets/icons/variable.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 10 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/procedural/CheckerNode.js: -------------------------------------------------------------------------------- 1 | import TempNode from '../core/TempNode.js'; 2 | import { uv } from '../accessors/UVNode.js'; 3 | import { addNodeClass } from '../core/Node.js'; 4 | import { addNodeElement, tslFn, nodeProxy } from '../shadernode/ShaderNode.js'; 5 | 6 | const checkerShaderNode = tslFn( ( inputs ) => { 7 | 8 | const uv = inputs.uv.mul( 2.0 ); 9 | 10 | const cx = uv.x.floor(); 11 | const cy = uv.y.floor(); 12 | const result = cx.add( cy ).mod( 2.0 ); 13 | 14 | return result.sign(); 15 | 16 | } ); 17 | 18 | class CheckerNode extends TempNode { 19 | 20 | constructor( uvNode = uv() ) { 21 | 22 | super( 'float' ); 23 | 24 | this.uvNode = uvNode; 25 | 26 | } 27 | 28 | setup() { 29 | 30 | return checkerShaderNode( { uv: this.uvNode } ); 31 | 32 | } 33 | 34 | } 35 | 36 | export default CheckerNode; 37 | 38 | export const checker = nodeProxy( CheckerNode ); 39 | 40 | addNodeElement( 'checker', checker ); 41 | 42 | addNodeClass( 'CheckerNode', CheckerNode ); 43 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/shaders/BlendShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Blend two textures 3 | */ 4 | 5 | const BlendShader = { 6 | 7 | name: 'BlendShader', 8 | 9 | uniforms: { 10 | 11 | 'tDiffuse1': { value: null }, 12 | 'tDiffuse2': { value: null }, 13 | 'mixRatio': { value: 0.5 }, 14 | 'opacity': { value: 1.0 } 15 | 16 | }, 17 | 18 | vertexShader: /* glsl */` 19 | 20 | varying vec2 vUv; 21 | 22 | void main() { 23 | 24 | vUv = uv; 25 | gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 26 | 27 | }`, 28 | 29 | fragmentShader: /* glsl */` 30 | 31 | uniform float opacity; 32 | uniform float mixRatio; 33 | 34 | uniform sampler2D tDiffuse1; 35 | uniform sampler2D tDiffuse2; 36 | 37 | varying vec2 vUv; 38 | 39 | void main() { 40 | 41 | vec4 texel1 = texture2D( tDiffuse1, vUv ); 42 | vec4 texel2 = texture2D( tDiffuse2, vUv ); 43 | gl_FragColor = opacity * mix( texel1, texel2, mixRatio ); 44 | 45 | }` 46 | 47 | }; 48 | 49 | export { BlendShader }; 50 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/controls/MapControls.js: -------------------------------------------------------------------------------- 1 | import { MOUSE, TOUCH } from 'three'; 2 | 3 | import { OrbitControls } from './OrbitControls.js'; 4 | 5 | // MapControls performs orbiting, dollying (zooming), and panning. 6 | // Unlike TrackballControls, it maintains the "up" direction object.up (+Y by default). 7 | // 8 | // Orbit - right mouse, or left mouse + ctrl/meta/shiftKey / touch: two-finger rotate 9 | // Zoom - middle mouse, or mousewheel / touch: two-finger spread or squish 10 | // Pan - left mouse, or arrow keys / touch: one-finger move 11 | 12 | class MapControls extends OrbitControls { 13 | 14 | constructor( object, domElement ) { 15 | 16 | super( object, domElement ); 17 | 18 | this.screenSpacePanning = false; // pan orthogonal to world-space direction camera.up 19 | 20 | this.mouseButtons = { LEFT: MOUSE.PAN, MIDDLE: MOUSE.DOLLY, RIGHT: MOUSE.ROTATE }; 21 | 22 | this.touches = { ONE: TOUCH.PAN, TWO: TOUCH.DOLLY_ROTATE }; 23 | 24 | } 25 | 26 | } 27 | 28 | export { MapControls }; 29 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/renderers/common/nodes/NodeBuilderState.js: -------------------------------------------------------------------------------- 1 | class NodeBuilderState { 2 | 3 | constructor( vertexShader, fragmentShader, computeShader, nodeAttributes, bindings, updateNodes, updateBeforeNodes ) { 4 | 5 | this.vertexShader = vertexShader; 6 | this.fragmentShader = fragmentShader; 7 | this.computeShader = computeShader; 8 | 9 | this.nodeAttributes = nodeAttributes; 10 | this.bindings = bindings; 11 | 12 | this.updateNodes = updateNodes; 13 | this.updateBeforeNodes = updateBeforeNodes; 14 | 15 | this.usedTimes = 0; 16 | 17 | } 18 | 19 | createBindings() { 20 | 21 | const bindingsArray = []; 22 | 23 | for ( const instanceBinding of this.bindings ) { 24 | 25 | let binding = instanceBinding; 26 | 27 | if ( instanceBinding.shared !== true ) { 28 | 29 | binding = instanceBinding.clone(); 30 | 31 | } 32 | 33 | bindingsArray.push( binding ); 34 | 35 | } 36 | 37 | return bindingsArray; 38 | 39 | } 40 | 41 | } 42 | 43 | export default NodeBuilderState; 44 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/display/ViewportSharedTextureNode.js: -------------------------------------------------------------------------------- 1 | import ViewportTextureNode from './ViewportTextureNode.js'; 2 | import { addNodeClass } from '../core/Node.js'; 3 | import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js'; 4 | import { viewportTopLeft } from './ViewportNode.js'; 5 | import { FramebufferTexture } from 'three'; 6 | 7 | let sharedFramebuffer = null; 8 | 9 | class ViewportSharedTextureNode extends ViewportTextureNode { 10 | 11 | constructor( uvNode = viewportTopLeft, levelNode = null ) { 12 | 13 | if ( sharedFramebuffer === null ) { 14 | 15 | sharedFramebuffer = new FramebufferTexture(); 16 | 17 | } 18 | 19 | super( uvNode, levelNode, sharedFramebuffer ); 20 | 21 | } 22 | 23 | } 24 | 25 | export default ViewportSharedTextureNode; 26 | 27 | export const viewportSharedTexture = nodeProxy( ViewportSharedTextureNode ); 28 | 29 | addNodeElement( 'viewportSharedTexture', viewportSharedTexture ); 30 | 31 | addNodeClass( 'ViewportSharedTextureNode', ViewportSharedTextureNode ); 32 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/functions/BSDF/DFGApprox.js: -------------------------------------------------------------------------------- 1 | import { tslFn, vec2, vec4 } from '../../shadernode/ShaderNode.js'; 2 | 3 | // Analytical approximation of the DFG LUT, one half of the 4 | // split-sum approximation used in indirect specular lighting. 5 | // via 'environmentBRDF' from "Physically Based Shading on Mobile" 6 | // https://www.unrealengine.com/blog/physically-based-shading-on-mobile 7 | const DFGApprox = tslFn( ( { roughness, dotNV } ) => { 8 | 9 | const c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); 10 | 11 | const c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); 12 | 13 | const r = roughness.mul( c0 ).add( c1 ); 14 | 15 | const a004 = r.x.mul( r.x ).min( dotNV.mul( - 9.28 ).exp2() ).mul( r.x ).add( r.y ); 16 | 17 | const fab = vec2( - 1.04, 1.04 ).mul( a004 ).add( r.zw ); 18 | 19 | return fab; 20 | 21 | } ).setLayout( { 22 | name: 'DFGApprox', 23 | type: 'vec2', 24 | inputs: [ 25 | { name: 'roughness', type: 'float' }, 26 | { name: 'dotNV', type: 'vec3' } 27 | ] 28 | } ); 29 | 30 | export default DFGApprox; 31 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/renderers/common/nodes/NodeSampledTexture.js: -------------------------------------------------------------------------------- 1 | import { SampledTexture } from '../SampledTexture.js'; 2 | 3 | class NodeSampledTexture extends SampledTexture { 4 | 5 | constructor( name, textureNode ) { 6 | 7 | super( name, textureNode ? textureNode.value : null ); 8 | 9 | this.textureNode = textureNode; 10 | 11 | } 12 | 13 | get needsBindingsUpdate() { 14 | 15 | return this.textureNode.value !== this.texture || super.needsBindingsUpdate; 16 | 17 | } 18 | 19 | update() { 20 | 21 | const { textureNode } = this; 22 | 23 | if ( this.texture !== textureNode.value ) { 24 | 25 | this.texture = textureNode.value; 26 | 27 | return true; 28 | 29 | } 30 | 31 | return super.update(); 32 | 33 | } 34 | 35 | } 36 | 37 | class NodeSampledCubeTexture extends NodeSampledTexture { 38 | 39 | constructor( name, textureNode ) { 40 | 41 | super( name, textureNode ); 42 | 43 | this.isSampledCubeTexture = true; 44 | 45 | } 46 | 47 | } 48 | 49 | export { NodeSampledTexture, NodeSampledCubeTexture }; 50 | -------------------------------------------------------------------------------- /src/pit/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 14 | 19 | 20 | 21 |
22 |
23 | 24 |
25 | 26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 | 34 | -------------------------------------------------------------------------------- /src/assets/logo-part-1.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/functions/BSDF/V_GGX_SmithCorrelated.js: -------------------------------------------------------------------------------- 1 | import { div } from '../../math/OperatorNode.js'; 2 | import { EPSILON } from '../../math/MathNode.js'; 3 | import { tslFn } from '../../shadernode/ShaderNode.js'; 4 | 5 | // Moving Frostbite to Physically Based Rendering 3.0 - page 12, listing 2 6 | // https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf 7 | const V_GGX_SmithCorrelated = tslFn( ( inputs ) => { 8 | 9 | const { alpha, dotNL, dotNV } = inputs; 10 | 11 | const a2 = alpha.pow2(); 12 | 13 | const gv = dotNL.mul( a2.add( a2.oneMinus().mul( dotNV.pow2() ) ).sqrt() ); 14 | const gl = dotNV.mul( a2.add( a2.oneMinus().mul( dotNL.pow2() ) ).sqrt() ); 15 | 16 | return div( 0.5, gv.add( gl ).max( EPSILON ) ); 17 | 18 | } ).setLayout( { 19 | name: 'V_GGX_SmithCorrelated', 20 | type: 'float', 21 | inputs: [ 22 | { name: 'alpha', type: 'float' }, 23 | { name: 'dotNL', type: 'float' }, 24 | { name: 'dotNV', type: 'float' } 25 | ] 26 | } ); // validated 27 | 28 | export default V_GGX_SmithCorrelated; 29 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/accessors/TextureSizeNode.js: -------------------------------------------------------------------------------- 1 | import Node from '../core/Node.js'; 2 | import { addNodeClass } from '../core/Node.js'; 3 | import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js'; 4 | 5 | class TextureSizeNode extends Node { 6 | 7 | constructor( textureNode, levelNode = null ) { 8 | 9 | super( 'uvec2' ); 10 | 11 | this.isTextureSizeNode = true; 12 | 13 | this.textureNode = textureNode; 14 | this.levelNode = levelNode; 15 | 16 | } 17 | 18 | generate( builder, output ) { 19 | 20 | const textureProperty = this.textureNode.build( builder, 'property' ); 21 | const levelNode = this.levelNode.build( builder, 'int' ); 22 | 23 | return builder.format( `${builder.getMethod( 'textureDimensions' )}( ${textureProperty}, ${levelNode} )`, this.getNodeType( builder ), output ); 24 | 25 | } 26 | 27 | } 28 | 29 | export default TextureSizeNode; 30 | 31 | export const textureSize = nodeProxy( TextureSizeNode ); 32 | 33 | addNodeElement( 'textureSize', textureSize ); 34 | 35 | addNodeClass( 'TextureSizeNode', TextureSizeNode ); 36 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/textures/FlakesTexture.js: -------------------------------------------------------------------------------- 1 | class FlakesTexture { 2 | 3 | constructor( width = 512, height = 512 ) { 4 | 5 | const canvas = document.createElement( 'canvas' ); 6 | canvas.width = width; 7 | canvas.height = height; 8 | 9 | const context = canvas.getContext( '2d' ); 10 | context.fillStyle = 'rgb(127,127,255)'; 11 | context.fillRect( 0, 0, width, height ); 12 | 13 | for ( let i = 0; i < 4000; i ++ ) { 14 | 15 | const x = Math.random() * width; 16 | const y = Math.random() * height; 17 | const r = Math.random() * 3 + 3; 18 | 19 | let nx = Math.random() * 2 - 1; 20 | let ny = Math.random() * 2 - 1; 21 | let nz = 1.5; 22 | 23 | const l = Math.sqrt( nx * nx + ny * ny + nz * nz ); 24 | 25 | nx /= l; ny /= l; nz /= l; 26 | 27 | context.fillStyle = 'rgb(' + ( nx * 127 + 127 ) + ',' + ( ny * 127 + 127 ) + ',' + ( nz * 255 ) + ')'; 28 | context.beginPath(); 29 | context.arc( x, y, r, 0, Math.PI * 2 ); 30 | context.fill(); 31 | 32 | } 33 | 34 | return canvas; 35 | 36 | } 37 | 38 | } 39 | 40 | export { FlakesTexture }; 41 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/lighting/IESSpotLightNode.js: -------------------------------------------------------------------------------- 1 | import SpotLightNode from './SpotLightNode.js'; 2 | import { addLightNode } from './LightsNode.js'; 3 | import { texture } from '../accessors/TextureNode.js'; 4 | import { vec2 } from '../shadernode/ShaderNode.js'; 5 | import { addNodeClass } from '../core/Node.js'; 6 | 7 | import IESSpotLight from '../../lights/IESSpotLight.js'; 8 | 9 | class IESSpotLightNode extends SpotLightNode { 10 | 11 | getSpotAttenuation( angleCosine ) { 12 | 13 | const iesMap = this.light.iesMap; 14 | 15 | let spotAttenuation = null; 16 | 17 | if ( iesMap && iesMap.isTexture === true ) { 18 | 19 | const angle = angleCosine.acos().mul( 1.0 / Math.PI ); 20 | 21 | spotAttenuation = texture( iesMap, vec2( angle, 0 ), 0 ).r; 22 | 23 | } else { 24 | 25 | spotAttenuation = super.getSpotAttenuation( angleCosine ); 26 | 27 | } 28 | 29 | return spotAttenuation; 30 | 31 | } 32 | 33 | } 34 | 35 | export default IESSpotLightNode; 36 | 37 | addNodeClass( 'IESSpotLightNode', IESSpotLightNode ); 38 | 39 | addLightNode( IESSpotLight, IESSpotLightNode ); 40 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/shaders/ColorCorrectionShader.js: -------------------------------------------------------------------------------- 1 | import { 2 | Vector3 3 | } from 'three'; 4 | 5 | /** 6 | * Color correction 7 | */ 8 | 9 | const ColorCorrectionShader = { 10 | 11 | name: 'ColorCorrectionShader', 12 | 13 | uniforms: { 14 | 15 | 'tDiffuse': { value: null }, 16 | 'powRGB': { value: new Vector3( 2, 2, 2 ) }, 17 | 'mulRGB': { value: new Vector3( 1, 1, 1 ) }, 18 | 'addRGB': { value: new Vector3( 0, 0, 0 ) } 19 | 20 | }, 21 | 22 | vertexShader: /* glsl */` 23 | 24 | varying vec2 vUv; 25 | 26 | void main() { 27 | 28 | vUv = uv; 29 | 30 | gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 31 | 32 | }`, 33 | 34 | fragmentShader: /* glsl */` 35 | 36 | uniform sampler2D tDiffuse; 37 | uniform vec3 powRGB; 38 | uniform vec3 mulRGB; 39 | uniform vec3 addRGB; 40 | 41 | varying vec2 vUv; 42 | 43 | void main() { 44 | 45 | gl_FragColor = texture2D( tDiffuse, vUv ); 46 | gl_FragColor.rgb = mulRGB * pow( ( gl_FragColor.rgb + addRGB ), powRGB ); 47 | 48 | }` 49 | 50 | }; 51 | 52 | export { ColorCorrectionShader }; 53 | -------------------------------------------------------------------------------- /src/panel/tabs/scouttab.js: -------------------------------------------------------------------------------- 1 | import * as util from "../../util.mjs"; 2 | import { V } from "../../util.mjs"; 3 | import * as lib from "../../lib.mjs"; 4 | 5 | import * as core from "../../core.mjs"; 6 | import { PROPERTYCACHE, GLOBALSTATE } from "../../core.mjs"; 7 | 8 | import * as app from "../../app.mjs"; 9 | 10 | 11 | import PanelToolTab from "./tooltab.js"; 12 | 13 | 14 | export default class PanelScoutTab extends PanelToolTab { 15 | #eWebView; 16 | 17 | static NAME = "Scout"; 18 | static NICKNAME = "Scout"; 19 | static ICON = "search-outline"; 20 | static ICONSRC = null; 21 | static ICONCOLOR = "var(--cc)"; 22 | 23 | constructor(a) { 24 | super(a); 25 | 26 | this.elem.classList.add("scout"); 27 | 28 | this.#eWebView = document.createElement("webview"); 29 | this.elem.appendChild(this.eWebView); 30 | (async () => { 31 | const scoutURL = await window.api.get("scout-url"); 32 | this.eWebView.setAttribute("src", scoutURL); 33 | })(); 34 | } 35 | 36 | get eWebView() { return this.#eWebView; } 37 | } 38 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/shaders/TechnicolorShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Technicolor Shader 3 | * Simulates the look of the two-strip technicolor process popular in early 20th century films. 4 | * More historical info here: http://www.widescreenmuseum.com/oldcolor/technicolor1.htm 5 | * Demo here: http://charliehoey.com/technicolor_shader/shader_test.html 6 | */ 7 | 8 | const TechnicolorShader = { 9 | 10 | name: 'TechnicolorShader', 11 | 12 | uniforms: { 13 | 14 | 'tDiffuse': { value: null } 15 | 16 | }, 17 | 18 | vertexShader: /* glsl */` 19 | 20 | varying vec2 vUv; 21 | 22 | void main() { 23 | 24 | vUv = uv; 25 | gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 26 | 27 | }`, 28 | 29 | fragmentShader: /* glsl */` 30 | 31 | uniform sampler2D tDiffuse; 32 | varying vec2 vUv; 33 | 34 | void main() { 35 | 36 | vec4 tex = texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ); 37 | vec4 newTex = vec4(tex.r, (tex.g + tex.b) * .5, (tex.g + tex.b) * .5, 1.0); 38 | 39 | gl_FragColor = newTex; 40 | 41 | }` 42 | 43 | }; 44 | 45 | export { TechnicolorShader }; 46 | -------------------------------------------------------------------------------- /src/assets/logo-part-4.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/materialx/lib/mx_transform_color.js: -------------------------------------------------------------------------------- 1 | // Three.js Transpiler 2 | // https://github.com/AcademySoftwareFoundation/MaterialX/blob/main/libraries/stdlib/genglsl/lib/mx_transform_color.glsl 3 | 4 | import { bvec3, vec3, tslFn } from '../../shadernode/ShaderNode.js'; 5 | import { greaterThan } from '../../math/OperatorNode.js'; 6 | import { max, pow, mix } from '../../math/MathNode.js'; 7 | 8 | const mx_srgb_texture_to_lin_rec709 = tslFn( ( [ color_immutable ] ) => { 9 | 10 | const color = vec3( color_immutable ).toVar(); 11 | const isAbove = bvec3( greaterThan( color, vec3( 0.04045 ) ) ).toVar(); 12 | const linSeg = vec3( color.div( 12.92 ) ).toVar(); 13 | const powSeg = vec3( pow( max( color.add( vec3( 0.055 ) ), vec3( 0.0 ) ).div( 1.055 ), vec3( 2.4 ) ) ).toVar(); 14 | 15 | return mix( linSeg, powSeg, isAbove ); 16 | 17 | } ); 18 | 19 | // layouts 20 | 21 | mx_srgb_texture_to_lin_rec709.setLayout( { 22 | name: 'mx_srgb_texture_to_lin_rec709', 23 | type: 'vec3', 24 | inputs: [ 25 | { name: 'color', type: 'vec3' } 26 | ] 27 | } ); 28 | 29 | export { mx_srgb_texture_to_lin_rec709 }; 30 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/lighting/DirectionalLightNode.js: -------------------------------------------------------------------------------- 1 | import AnalyticLightNode from './AnalyticLightNode.js'; 2 | import { lightTargetDirection } from './LightNode.js'; 3 | import { addLightNode } from './LightsNode.js'; 4 | import { addNodeClass } from '../core/Node.js'; 5 | 6 | import { DirectionalLight } from 'three'; 7 | 8 | class DirectionalLightNode extends AnalyticLightNode { 9 | 10 | constructor( light = null ) { 11 | 12 | super( light ); 13 | 14 | } 15 | 16 | setup( builder ) { 17 | 18 | super.setup( builder ); 19 | 20 | const lightingModel = builder.context.lightingModel; 21 | 22 | const lightColor = this.colorNode; 23 | const lightDirection = lightTargetDirection( this.light ); 24 | const reflectedLight = builder.context.reflectedLight; 25 | 26 | lightingModel.direct( { 27 | lightDirection, 28 | lightColor, 29 | reflectedLight 30 | }, builder.stack, builder ); 31 | 32 | } 33 | 34 | } 35 | 36 | export default DirectionalLightNode; 37 | 38 | addNodeClass( 'DirectionalLightNode', DirectionalLightNode ); 39 | 40 | addLightNode( DirectionalLight, DirectionalLightNode ); 41 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/postprocessing/ClearPass.js: -------------------------------------------------------------------------------- 1 | import { 2 | Color 3 | } from 'three'; 4 | import { Pass } from './Pass.js'; 5 | 6 | class ClearPass extends Pass { 7 | 8 | constructor( clearColor, clearAlpha ) { 9 | 10 | super(); 11 | 12 | this.needsSwap = false; 13 | 14 | this.clearColor = ( clearColor !== undefined ) ? clearColor : 0x000000; 15 | this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0; 16 | this._oldClearColor = new Color(); 17 | 18 | } 19 | 20 | render( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) { 21 | 22 | let oldClearAlpha; 23 | 24 | if ( this.clearColor ) { 25 | 26 | renderer.getClearColor( this._oldClearColor ); 27 | oldClearAlpha = renderer.getClearAlpha(); 28 | 29 | renderer.setClearColor( this.clearColor, this.clearAlpha ); 30 | 31 | } 32 | 33 | renderer.setRenderTarget( this.renderToScreen ? null : readBuffer ); 34 | renderer.clear(); 35 | 36 | if ( this.clearColor ) { 37 | 38 | renderer.setClearColor( this._oldClearColor, oldClearAlpha ); 39 | 40 | } 41 | 42 | } 43 | 44 | } 45 | 46 | export { ClearPass }; 47 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/shaders/VignetteShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Vignette shader 3 | * based on PaintEffect postprocess from ro.me 4 | * http://code.google.com/p/3-dreams-of-black/source/browse/deploy/js/effects/PaintEffect.js 5 | */ 6 | 7 | const VignetteShader = { 8 | 9 | name: 'VignetteShader', 10 | 11 | uniforms: { 12 | 13 | 'tDiffuse': { value: null }, 14 | 'offset': { value: 1.0 }, 15 | 'darkness': { value: 1.0 } 16 | 17 | }, 18 | 19 | vertexShader: /* glsl */` 20 | 21 | varying vec2 vUv; 22 | 23 | void main() { 24 | 25 | vUv = uv; 26 | gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 27 | 28 | }`, 29 | 30 | fragmentShader: /* glsl */` 31 | 32 | uniform float offset; 33 | uniform float darkness; 34 | 35 | uniform sampler2D tDiffuse; 36 | 37 | varying vec2 vUv; 38 | 39 | void main() { 40 | 41 | // Eskil's vignette 42 | 43 | vec4 texel = texture2D( tDiffuse, vUv ); 44 | vec2 uv = ( vUv - vec2( 0.5 ) ) * vec2( offset ); 45 | gl_FragColor = vec4( mix( texel.rgb, vec3( 1.0 - darkness ), dot( uv, uv ) ), texel.a ); 46 | 47 | }` 48 | 49 | }; 50 | 51 | export { VignetteShader }; 52 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/accessors/ModelViewProjectionNode.js: -------------------------------------------------------------------------------- 1 | import { addNodeClass } from '../core/Node.js'; 2 | import TempNode from '../core/TempNode.js'; 3 | import { cameraProjectionMatrix } from './CameraNode.js'; 4 | import { modelViewMatrix } from './ModelNode.js'; 5 | import { positionLocal } from './PositionNode.js'; 6 | import { nodeProxy } from '../shadernode/ShaderNode.js'; 7 | import { varying } from '../core/VaryingNode.js'; 8 | 9 | class ModelViewProjectionNode extends TempNode { 10 | 11 | constructor( positionNode = null ) { 12 | 13 | super( 'vec4' ); 14 | 15 | this.positionNode = positionNode; 16 | 17 | } 18 | 19 | setup( builder ) { 20 | 21 | if ( builder.shaderStage === 'fragment' ) { 22 | 23 | return varying( builder.context.mvp ); 24 | 25 | } 26 | 27 | const position = this.positionNode || positionLocal; 28 | 29 | return cameraProjectionMatrix.mul( modelViewMatrix ).mul( position ); 30 | 31 | } 32 | 33 | } 34 | 35 | export default ModelViewProjectionNode; 36 | 37 | export const modelViewProjection = nodeProxy( ModelViewProjectionNode ); 38 | 39 | addNodeClass( 'ModelViewProjectionNode', ModelViewProjectionNode ); 40 | -------------------------------------------------------------------------------- /src/assets/logo-part-3.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/renderers/webgpu/WebGPURenderer.js: -------------------------------------------------------------------------------- 1 | import Renderer from '../common/Renderer.js'; 2 | import WebGLBackend from '../webgl/WebGLBackend.js'; 3 | import WebGPUBackend from './WebGPUBackend.js'; 4 | import WebGPU from '../../capabilities/WebGPU.js'; 5 | /* 6 | const debugHandler = { 7 | 8 | get: function ( target, name ) { 9 | 10 | // Add |update 11 | if ( /^(create|destroy)/.test( name ) ) console.log( 'WebGPUBackend.' + name ); 12 | 13 | return target[ name ]; 14 | 15 | } 16 | 17 | }; 18 | */ 19 | class WebGPURenderer extends Renderer { 20 | 21 | constructor( parameters = {} ) { 22 | 23 | let BackendClass; 24 | 25 | if ( WebGPU.isAvailable() ) { 26 | 27 | BackendClass = WebGPUBackend; 28 | 29 | } else { 30 | 31 | BackendClass = WebGLBackend; 32 | 33 | console.warn( 'THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend.' ); 34 | 35 | } 36 | 37 | const backend = new BackendClass( parameters ); 38 | 39 | //super( new Proxy( backend, debugHandler ) ); 40 | super( backend, parameters ); 41 | 42 | this.isWebGPURenderer = true; 43 | 44 | } 45 | 46 | } 47 | 48 | export default WebGPURenderer; 49 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/utils/MaxMipLevelNode.js: -------------------------------------------------------------------------------- 1 | import UniformNode from '../core/UniformNode.js'; 2 | import { NodeUpdateType } from '../core/constants.js'; 3 | import { nodeProxy } from '../shadernode/ShaderNode.js'; 4 | import { addNodeClass } from '../core/Node.js'; 5 | 6 | class MaxMipLevelNode extends UniformNode { 7 | 8 | constructor( textureNode ) { 9 | 10 | super( 0 ); 11 | 12 | this.textureNode = textureNode; 13 | 14 | this.updateType = NodeUpdateType.FRAME; 15 | 16 | } 17 | 18 | get texture() { 19 | 20 | return this.textureNode.value; 21 | 22 | } 23 | 24 | update() { 25 | 26 | const texture = this.texture; 27 | const images = texture.images; 28 | const image = ( images && images.length > 0 ) ? ( ( images[ 0 ] && images[ 0 ].image ) || images[ 0 ] ) : texture.image; 29 | 30 | if ( image && image.width !== undefined ) { 31 | 32 | const { width, height } = image; 33 | 34 | this.value = Math.log2( Math.max( width, height ) ); 35 | 36 | } 37 | 38 | } 39 | 40 | } 41 | 42 | export default MaxMipLevelNode; 43 | 44 | export const maxMipLevel = nodeProxy( MaxMipLevelNode ); 45 | 46 | addNodeClass( 'MaxMipLevelNode', MaxMipLevelNode ); 47 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/utils/SpriteSheetUVNode.js: -------------------------------------------------------------------------------- 1 | import Node, { addNodeClass } from '../core/Node.js'; 2 | import { uv } from '../accessors/UVNode.js'; 3 | import { nodeProxy, float, vec2 } from '../shadernode/ShaderNode.js'; 4 | 5 | class SpriteSheetUVNode extends Node { 6 | 7 | constructor( countNode, uvNode = uv(), frameNode = float( 0 ) ) { 8 | 9 | super( 'vec2' ); 10 | 11 | this.countNode = countNode; 12 | this.uvNode = uvNode; 13 | this.frameNode = frameNode; 14 | 15 | } 16 | 17 | setup() { 18 | 19 | const { frameNode, uvNode, countNode } = this; 20 | 21 | const { width, height } = countNode; 22 | 23 | const frameNum = frameNode.mod( width.mul( height ) ).floor(); 24 | 25 | const column = frameNum.mod( width ); 26 | const row = height.sub( frameNum.add( 1 ).div( width ).ceil() ); 27 | 28 | const scale = countNode.reciprocal(); 29 | const uvFrameOffset = vec2( column, row ); 30 | 31 | return uvNode.add( uvFrameOffset ).mul( scale ); 32 | 33 | } 34 | 35 | } 36 | 37 | export default SpriteSheetUVNode; 38 | 39 | export const spritesheetUV = nodeProxy( SpriteSheetUVNode ); 40 | 41 | addNodeClass( 'SpriteSheetUVNode', SpriteSheetUVNode ); 42 | -------------------------------------------------------------------------------- /src/planner/solver/motor.py: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | high_tide_mode = False 4 | 5 | efficiency_tweak = 0.7 6 | 7 | with open('data.in', 'r') as file: 8 | data = json.load(file) 9 | 10 | config = data['config'] 11 | 12 | efficiency_tweak = config['efficiency_percent'] 13 | FOC = config['FOC'] 14 | 15 | nominal_voltage = 12 16 | 17 | drive_gr_falcon = 6.75 18 | drive_gr_kraken = 1.0 / ((16.0 / 50) * (28.0 / 16) * (15.0 / 45)) 19 | 20 | stall_torque = 7.09 * drive_gr_kraken * efficiency_tweak 21 | 22 | stall_current = 366 23 | free_current = 2.0 24 | 25 | free_speed = 6000 / drive_gr_kraken 26 | 27 | if FOC: 28 | stall_torque = 9.37 * drive_gr_kraken * efficiency_tweak 29 | stall_current = 483 30 | free_current = 2 31 | free_speed = 5800 / drive_gr_kraken 32 | 33 | rOhms = nominal_voltage / stall_current 34 | 35 | Kv_rad_per_sec_per_volt = (2 * 3.1415 * free_speed / 60) / (nominal_voltage - rOhms * free_current) 36 | 37 | Kt_NM_per_amp = stall_torque / stall_current 38 | 39 | def get_current(rad_per_s, voltage): 40 | return -1 / Kv_rad_per_sec_per_volt / rOhms * rad_per_s + 1 / rOhms * voltage 41 | 42 | def get_torque(current): 43 | return current * Kt_NM_per_amp 44 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/core/CacheNode.js: -------------------------------------------------------------------------------- 1 | import Node, { addNodeClass } from './Node.js'; 2 | import NodeCache from './NodeCache.js'; 3 | import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js'; 4 | 5 | class CacheNode extends Node { 6 | 7 | constructor( node, cache = new NodeCache() ) { 8 | 9 | super(); 10 | 11 | this.isCacheNode = true; 12 | 13 | this.node = node; 14 | this.cache = cache; 15 | 16 | } 17 | 18 | getNodeType( builder ) { 19 | 20 | return this.node.getNodeType( builder ); 21 | 22 | } 23 | 24 | build( builder, ...params ) { 25 | 26 | const previousCache = builder.getCache(); 27 | const cache = this.cache || builder.globalCache; 28 | 29 | builder.setCache( cache ); 30 | 31 | const data = this.node.build( builder, ...params ); 32 | 33 | builder.setCache( previousCache ); 34 | 35 | return data; 36 | 37 | } 38 | 39 | } 40 | 41 | export default CacheNode; 42 | 43 | export const cache = nodeProxy( CacheNode ); 44 | export const globalCache = ( node ) => cache( node, null ); 45 | 46 | addNodeElement( 'cache', cache ); 47 | addNodeElement( 'globalCache', globalCache ); 48 | 49 | addNodeClass( 'CacheNode', CacheNode ); 50 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/utils/SpecularMIPLevelNode.js: -------------------------------------------------------------------------------- 1 | import Node, { addNodeClass } from '../core/Node.js'; 2 | import { maxMipLevel } from './MaxMipLevelNode.js'; 3 | import { nodeProxy } from '../shadernode/ShaderNode.js'; 4 | 5 | class SpecularMIPLevelNode extends Node { 6 | 7 | constructor( textureNode, roughnessNode = null ) { 8 | 9 | super( 'float' ); 10 | 11 | this.textureNode = textureNode; 12 | this.roughnessNode = roughnessNode; 13 | 14 | } 15 | 16 | setup() { 17 | 18 | const { textureNode, roughnessNode } = this; 19 | 20 | // taken from here: http://casual-effects.blogspot.ca/2011/08/plausible-environment-lighting-in-two.html 21 | 22 | const maxMIPLevelScalar = maxMipLevel( textureNode ); 23 | 24 | const sigma = roughnessNode.mul( roughnessNode ).mul( Math.PI ).div( roughnessNode.add( 1.0 ) ); 25 | const desiredMIPLevel = maxMIPLevelScalar.add( sigma.log2() ); 26 | 27 | return desiredMIPLevel.clamp( 0.0, maxMIPLevelScalar ); 28 | 29 | } 30 | 31 | } 32 | 33 | export default SpecularMIPLevelNode; 34 | 35 | export const specularMIPLevel = nodeProxy( SpecularMIPLevelNode ); 36 | 37 | addNodeClass( 'SpecularMIPLevelNode', SpecularMIPLevelNode ); 38 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/shaders/AfterimageShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Afterimage shader 3 | * I created this effect inspired by a demo on codepen: 4 | * https://codepen.io/brunoimbrizi/pen/MoRJaN?page=1& 5 | */ 6 | 7 | const AfterimageShader = { 8 | 9 | name: 'AfterimageShader', 10 | 11 | uniforms: { 12 | 13 | 'damp': { value: 0.96 }, 14 | 'tOld': { value: null }, 15 | 'tNew': { value: null } 16 | 17 | }, 18 | 19 | vertexShader: /* glsl */` 20 | 21 | varying vec2 vUv; 22 | 23 | void main() { 24 | 25 | vUv = uv; 26 | gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 27 | 28 | }`, 29 | 30 | fragmentShader: /* glsl */` 31 | 32 | uniform float damp; 33 | 34 | uniform sampler2D tOld; 35 | uniform sampler2D tNew; 36 | 37 | varying vec2 vUv; 38 | 39 | vec4 when_gt( vec4 x, float y ) { 40 | 41 | return max( sign( x - y ), 0.0 ); 42 | 43 | } 44 | 45 | void main() { 46 | 47 | vec4 texelOld = texture2D( tOld, vUv ); 48 | vec4 texelNew = texture2D( tNew, vUv ); 49 | 50 | texelOld *= damp * when_gt( texelOld, 0.1 ); 51 | 52 | gl_FragColor = max(texelNew, texelOld); 53 | 54 | }` 55 | 56 | }; 57 | 58 | export { AfterimageShader }; 59 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/shaders/MirrorShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Mirror Shader 3 | * Copies half the input to the other half 4 | * 5 | * side: side of input to mirror (0 = left, 1 = right, 2 = top, 3 = bottom) 6 | */ 7 | 8 | const MirrorShader = { 9 | 10 | name: 'MirrorShader', 11 | 12 | uniforms: { 13 | 14 | 'tDiffuse': { value: null }, 15 | 'side': { value: 1 } 16 | 17 | }, 18 | 19 | vertexShader: /* glsl */` 20 | 21 | varying vec2 vUv; 22 | 23 | void main() { 24 | 25 | vUv = uv; 26 | gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 27 | 28 | }`, 29 | 30 | fragmentShader: /* glsl */` 31 | 32 | uniform sampler2D tDiffuse; 33 | uniform int side; 34 | 35 | varying vec2 vUv; 36 | 37 | void main() { 38 | 39 | vec2 p = vUv; 40 | if (side == 0){ 41 | if (p.x > 0.5) p.x = 1.0 - p.x; 42 | }else if (side == 1){ 43 | if (p.x < 0.5) p.x = 1.0 - p.x; 44 | }else if (side == 2){ 45 | if (p.y < 0.5) p.y = 1.0 - p.y; 46 | }else if (side == 3){ 47 | if (p.y > 0.5) p.y = 1.0 - p.y; 48 | } 49 | vec4 color = texture2D(tDiffuse, p); 50 | gl_FragColor = color; 51 | 52 | }` 53 | 54 | }; 55 | 56 | export { MirrorShader }; 57 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/shaders/SepiaShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sepia tone shader 3 | * based on glfx.js sepia shader 4 | * https://github.com/evanw/glfx.js 5 | */ 6 | 7 | const SepiaShader = { 8 | 9 | name: 'SepiaShader', 10 | 11 | uniforms: { 12 | 13 | 'tDiffuse': { value: null }, 14 | 'amount': { value: 1.0 } 15 | 16 | }, 17 | 18 | vertexShader: /* glsl */` 19 | 20 | varying vec2 vUv; 21 | 22 | void main() { 23 | 24 | vUv = uv; 25 | gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 26 | 27 | }`, 28 | 29 | fragmentShader: /* glsl */` 30 | 31 | uniform float amount; 32 | 33 | uniform sampler2D tDiffuse; 34 | 35 | varying vec2 vUv; 36 | 37 | void main() { 38 | 39 | vec4 color = texture2D( tDiffuse, vUv ); 40 | vec3 c = color.rgb; 41 | 42 | color.r = dot( c, vec3( 1.0 - 0.607 * amount, 0.769 * amount, 0.189 * amount ) ); 43 | color.g = dot( c, vec3( 0.349 * amount, 1.0 - 0.314 * amount, 0.168 * amount ) ); 44 | color.b = dot( c, vec3( 0.272 * amount, 0.534 * amount, 1.0 - 0.869 * amount ) ); 45 | 46 | gl_FragColor = vec4( min( vec3( 1.0 ), color.rgb ), color.a ); 47 | 48 | }` 49 | 50 | }; 51 | 52 | export { SepiaShader }; 53 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/shaders/DOFMipMapShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Depth-of-field shader using mipmaps 3 | * - from Matt Handley @applmak 4 | * - requires power-of-2 sized render target with enabled mipmaps 5 | */ 6 | 7 | const DOFMipMapShader = { 8 | 9 | name: 'DOFMipMapShader', 10 | 11 | uniforms: { 12 | 13 | 'tColor': { value: null }, 14 | 'tDepth': { value: null }, 15 | 'focus': { value: 1.0 }, 16 | 'maxblur': { value: 1.0 } 17 | 18 | }, 19 | 20 | vertexShader: /* glsl */` 21 | 22 | varying vec2 vUv; 23 | 24 | void main() { 25 | 26 | vUv = uv; 27 | gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 28 | 29 | }`, 30 | 31 | fragmentShader: /* glsl */` 32 | 33 | uniform float focus; 34 | uniform float maxblur; 35 | 36 | uniform sampler2D tColor; 37 | uniform sampler2D tDepth; 38 | 39 | varying vec2 vUv; 40 | 41 | void main() { 42 | 43 | vec4 depth = texture2D( tDepth, vUv ); 44 | 45 | float factor = depth.x - focus; 46 | 47 | vec4 col = texture2D( tColor, vUv, 2.0 * maxblur * abs( focus - depth.x ) ); 48 | 49 | gl_FragColor = col; 50 | gl_FragColor.a = 1.0; 51 | 52 | }` 53 | 54 | }; 55 | 56 | export { DOFMipMapShader }; 57 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/webxr/Text2D.js: -------------------------------------------------------------------------------- 1 | import * as THREE from 'three'; 2 | 3 | function createText( message, height ) { 4 | 5 | const canvas = document.createElement( 'canvas' ); 6 | const context = canvas.getContext( '2d' ); 7 | let metrics = null; 8 | const textHeight = 100; 9 | context.font = 'normal ' + textHeight + 'px Arial'; 10 | metrics = context.measureText( message ); 11 | const textWidth = metrics.width; 12 | canvas.width = textWidth; 13 | canvas.height = textHeight; 14 | context.font = 'normal ' + textHeight + 'px Arial'; 15 | context.textAlign = 'center'; 16 | context.textBaseline = 'middle'; 17 | context.fillStyle = '#ffffff'; 18 | context.fillText( message, textWidth / 2, textHeight / 2 ); 19 | 20 | const texture = new THREE.Texture( canvas ); 21 | texture.needsUpdate = true; 22 | 23 | const material = new THREE.MeshBasicMaterial( { 24 | color: 0xffffff, 25 | side: THREE.DoubleSide, 26 | map: texture, 27 | transparent: true, 28 | } ); 29 | const geometry = new THREE.PlaneGeometry( 30 | ( height * textWidth ) / textHeight, 31 | height 32 | ); 33 | const plane = new THREE.Mesh( geometry, material ); 34 | return plane; 35 | 36 | } 37 | 38 | export { createText }; 39 | -------------------------------------------------------------------------------- /src/assets/icons/robot.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | 16 | 18 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/accessors/ModelNode.js: -------------------------------------------------------------------------------- 1 | import Object3DNode from './Object3DNode.js'; 2 | import { addNodeClass } from '../core/Node.js'; 3 | import { nodeImmutable } from '../shadernode/ShaderNode.js'; 4 | 5 | class ModelNode extends Object3DNode { 6 | 7 | constructor( scope = ModelNode.VIEW_MATRIX ) { 8 | 9 | super( scope ); 10 | 11 | } 12 | 13 | update( frame ) { 14 | 15 | this.object3d = frame.object; 16 | 17 | super.update( frame ); 18 | 19 | } 20 | 21 | } 22 | 23 | export default ModelNode; 24 | 25 | export const modelDirection = nodeImmutable( ModelNode, ModelNode.DIRECTION ); 26 | export const modelViewMatrix = nodeImmutable( ModelNode, ModelNode.VIEW_MATRIX ).label( 'modelViewMatrix' ).temp( 'ModelViewMatrix' ); 27 | export const modelNormalMatrix = nodeImmutable( ModelNode, ModelNode.NORMAL_MATRIX ); 28 | export const modelWorldMatrix = nodeImmutable( ModelNode, ModelNode.WORLD_MATRIX ); 29 | export const modelPosition = nodeImmutable( ModelNode, ModelNode.POSITION ); 30 | export const modelScale = nodeImmutable( ModelNode, ModelNode.SCALE ); 31 | export const modelViewPosition = nodeImmutable( ModelNode, ModelNode.VIEW_POSITION ); 32 | 33 | addNodeClass( 'ModelNode', ModelNode ); 34 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/shaders/FilmShader.js: -------------------------------------------------------------------------------- 1 | const FilmShader = { 2 | 3 | name: 'FilmShader', 4 | 5 | uniforms: { 6 | 7 | 'tDiffuse': { value: null }, 8 | 'time': { value: 0.0 }, 9 | 'intensity': { value: 0.5 }, 10 | 'grayscale': { value: false } 11 | 12 | }, 13 | 14 | vertexShader: /* glsl */` 15 | 16 | varying vec2 vUv; 17 | 18 | void main() { 19 | 20 | vUv = uv; 21 | gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 22 | 23 | }`, 24 | 25 | fragmentShader: /* glsl */` 26 | 27 | #include 28 | 29 | uniform float intensity; 30 | uniform bool grayscale; 31 | uniform float time; 32 | 33 | uniform sampler2D tDiffuse; 34 | 35 | varying vec2 vUv; 36 | 37 | void main() { 38 | 39 | vec4 base = texture2D( tDiffuse, vUv ); 40 | 41 | float noise = rand( fract( vUv + time ) ); 42 | 43 | vec3 color = base.rgb + base.rgb * clamp( 0.1 + noise, 0.0, 1.0 ); 44 | 45 | color = mix( base.rgb, color, intensity ); 46 | 47 | if ( grayscale ) { 48 | 49 | color = vec3( luminance( color ) ); // assuming linear-srgb 50 | 51 | } 52 | 53 | gl_FragColor = vec4( color, base.a ); 54 | 55 | }`, 56 | 57 | }; 58 | 59 | export { FilmShader }; 60 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/accessors/CubeTextureNode.js: -------------------------------------------------------------------------------- 1 | import TextureNode from './TextureNode.js'; 2 | import { reflectVector } from './ReflectVectorNode.js'; 3 | import { addNodeClass } from '../core/Node.js'; 4 | import { addNodeElement, nodeProxy, vec3 } from '../shadernode/ShaderNode.js'; 5 | 6 | class CubeTextureNode extends TextureNode { 7 | 8 | constructor( value, uvNode = null, levelNode = null ) { 9 | 10 | super( value, uvNode, levelNode ); 11 | 12 | this.isCubeTextureNode = true; 13 | 14 | } 15 | 16 | getInputType( /*builder*/ ) { 17 | 18 | return 'cubeTexture'; 19 | 20 | } 21 | 22 | getDefaultUV() { 23 | 24 | return reflectVector; 25 | 26 | } 27 | 28 | setUpdateMatrix( /*updateMatrix*/ ) { } // Ignore .updateMatrix for CubeTextureNode 29 | 30 | setupUV( builder, uvNode ) { 31 | 32 | return vec3( uvNode.x.negate(), uvNode.yz ); 33 | 34 | } 35 | 36 | generateUV( builder, cubeUV ) { 37 | 38 | return cubeUV.build( builder, 'vec3' ); 39 | 40 | } 41 | 42 | } 43 | 44 | export default CubeTextureNode; 45 | 46 | export const cubeTexture = nodeProxy( CubeTextureNode ); 47 | 48 | addNodeElement( 'cubeTexture', cubeTexture ); 49 | 50 | addNodeClass( 'CubeTextureNode', CubeTextureNode ); 51 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/display/ViewportDepthTextureNode.js: -------------------------------------------------------------------------------- 1 | import ViewportTextureNode from './ViewportTextureNode.js'; 2 | import { addNodeClass } from '../core/Node.js'; 3 | import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js'; 4 | import { viewportTopLeft } from './ViewportNode.js'; 5 | import { DepthTexture, NearestMipmapNearestFilter, DepthFormat, UnsignedIntType } from 'three'; 6 | 7 | let sharedDepthbuffer = null; 8 | 9 | class ViewportDepthTextureNode extends ViewportTextureNode { 10 | 11 | constructor( uvNode = viewportTopLeft, levelNode = null ) { 12 | 13 | if ( sharedDepthbuffer === null ) { 14 | 15 | sharedDepthbuffer = new DepthTexture(); 16 | sharedDepthbuffer.minFilter = NearestMipmapNearestFilter; 17 | sharedDepthbuffer.type = UnsignedIntType; 18 | sharedDepthbuffer.format = DepthFormat; 19 | 20 | } 21 | 22 | super( uvNode, levelNode, sharedDepthbuffer ); 23 | 24 | } 25 | 26 | } 27 | 28 | export default ViewportDepthTextureNode; 29 | 30 | export const viewportDepthTexture = nodeProxy( ViewportDepthTextureNode ); 31 | 32 | addNodeElement( 'viewportDepthTexture', viewportDepthTexture ); 33 | 34 | addNodeClass( 'ViewportDepthTextureNode', ViewportDepthTextureNode ); 35 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/utils/RemapNode.js: -------------------------------------------------------------------------------- 1 | import Node, { addNodeClass } from '../core/Node.js'; 2 | import { float, addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js'; 3 | 4 | class RemapNode extends Node { 5 | 6 | constructor( node, inLowNode, inHighNode, outLowNode = float( 0 ), outHighNode = float( 1 ) ) { 7 | 8 | super(); 9 | 10 | this.node = node; 11 | this.inLowNode = inLowNode; 12 | this.inHighNode = inHighNode; 13 | this.outLowNode = outLowNode; 14 | this.outHighNode = outHighNode; 15 | 16 | this.doClamp = true; 17 | 18 | } 19 | 20 | setup() { 21 | 22 | const { node, inLowNode, inHighNode, outLowNode, outHighNode, doClamp } = this; 23 | 24 | let t = node.sub( inLowNode ).div( inHighNode.sub( inLowNode ) ); 25 | 26 | if ( doClamp === true ) t = t.clamp(); 27 | 28 | return t.mul( outHighNode.sub( outLowNode ) ).add( outLowNode ); 29 | 30 | } 31 | 32 | } 33 | 34 | export default RemapNode; 35 | 36 | export const remap = nodeProxy( RemapNode, null, null, { doClamp: false } ); 37 | export const remapClamp = nodeProxy( RemapNode ); 38 | 39 | addNodeElement( 'remap', remap ); 40 | addNodeElement( 'remapClamp', remapClamp ); 41 | 42 | addNodeClass( 'RemapNode', RemapNode ); 43 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/loaders/NodeMaterialLoader.js: -------------------------------------------------------------------------------- 1 | import { MaterialLoader } from 'three'; 2 | import { createNodeMaterialFromType } from '../materials/Materials.js'; 3 | 4 | const superFromTypeFunction = MaterialLoader.createMaterialFromType; 5 | 6 | MaterialLoader.createMaterialFromType = function ( type ) { 7 | 8 | const material = createNodeMaterialFromType( type ); 9 | 10 | if ( material !== undefined ) { 11 | 12 | return material; 13 | 14 | } 15 | 16 | return superFromTypeFunction.call( this, type ); 17 | 18 | }; 19 | 20 | class NodeMaterialLoader extends MaterialLoader { 21 | 22 | constructor( manager ) { 23 | 24 | super( manager ); 25 | 26 | this.nodes = {}; 27 | 28 | } 29 | 30 | parse( json ) { 31 | 32 | const material = super.parse( json ); 33 | 34 | const nodes = this.nodes; 35 | const inputNodes = json.inputNodes; 36 | 37 | for ( const property in inputNodes ) { 38 | 39 | const uuid = inputNodes[ property ]; 40 | 41 | material[ property ] = nodes[ uuid ]; 42 | 43 | } 44 | 45 | return material; 46 | 47 | } 48 | 49 | setNodes( value ) { 50 | 51 | this.nodes = value; 52 | 53 | return this; 54 | 55 | } 56 | 57 | } 58 | 59 | export default NodeMaterialLoader; 60 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/utils/RotateUVNode.js: -------------------------------------------------------------------------------- 1 | import TempNode from '../core/TempNode.js'; 2 | import { addNodeClass } from '../core/Node.js'; 3 | import { addNodeElement, nodeProxy, vec2 } from '../shadernode/ShaderNode.js'; 4 | 5 | class RotateUVNode extends TempNode { 6 | 7 | constructor( uvNode, rotationNode, centerNode = vec2( 0.5 ) ) { 8 | 9 | super( 'vec2' ); 10 | 11 | this.uvNode = uvNode; 12 | this.rotationNode = rotationNode; 13 | this.centerNode = centerNode; 14 | 15 | } 16 | 17 | setup() { 18 | 19 | const { uvNode, rotationNode, centerNode } = this; 20 | 21 | const cosAngle = rotationNode.cos(); 22 | const sinAngle = rotationNode.sin(); 23 | 24 | const vector = uvNode.sub( centerNode ); 25 | 26 | const rotatedVector = vec2( // @TODO: Maybe we can create mat2 and write something like rotationMatrix.mul( vector )? 27 | vec2( cosAngle, sinAngle ).dot( vector ), 28 | vec2( sinAngle.negate(), cosAngle ).dot( vector ) 29 | ); 30 | 31 | return rotatedVector.add( centerNode ); 32 | 33 | } 34 | 35 | } 36 | 37 | export default RotateUVNode; 38 | 39 | export const rotateUV = nodeProxy( RotateUVNode ); 40 | 41 | addNodeElement( 'rotateUV', rotateUV ); 42 | 43 | addNodeClass( 'RotateUVNode', RotateUVNode ); 44 | -------------------------------------------------------------------------------- /src/sources/ds/source.js: -------------------------------------------------------------------------------- 1 | import * as util from "../../util.mjs"; 2 | import * as lib from "../../lib.mjs"; 3 | 4 | import { WorkerClient } from "../../worker.js"; 5 | 6 | import HistoricalSource from "../historical-source.js"; 7 | 8 | 9 | export default class DSSource extends HistoricalSource { 10 | static CLIENTDECODER = "./sources/ds/decoder-worker.js"; 11 | static CLIENTENCODER = null; 12 | static TYPE = "ds"; 13 | static WANTED = "uint8"; 14 | 15 | static getName() { return "DriverStation"; } 16 | 17 | constructor() { 18 | super(); 19 | } 20 | 21 | static cast(data) { 22 | data = util.ensure(data, "obj"); 23 | data.logData = super.cast(data.logData); 24 | data.eventsData = super.cast(data.eventsData); 25 | return data; 26 | } 27 | static async fetch(pth) { 28 | let {logPth, eventsPth} = lib.getDSPaths(pth); 29 | let [logData, eventsData] = await Promise.all([logPth, eventsPth].map(async pth => await super.fetch(pth))); 30 | return { 31 | logData: logData, 32 | eventsData: eventsData, 33 | }; 34 | } 35 | 36 | static async export(source, prefix="") { throw new Error("Exporting of DSSource is not supported"); } 37 | } 38 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/materials/MeshNormalNodeMaterial.js: -------------------------------------------------------------------------------- 1 | import NodeMaterial, { addNodeMaterial } from './NodeMaterial.js'; 2 | import { diffuseColor } from '../core/PropertyNode.js'; 3 | import { directionToColor } from '../utils/PackingNode.js'; 4 | import { materialOpacity } from '../accessors/MaterialNode.js'; 5 | import { transformedNormalView } from '../accessors/NormalNode.js'; 6 | import { float, vec4 } from '../shadernode/ShaderNode.js'; 7 | 8 | import { MeshNormalMaterial } from 'three'; 9 | 10 | const defaultValues = new MeshNormalMaterial(); 11 | 12 | class MeshNormalNodeMaterial extends NodeMaterial { 13 | 14 | constructor( parameters ) { 15 | 16 | super(); 17 | 18 | this.isMeshNormalNodeMaterial = true; 19 | 20 | this.colorSpaced = false; 21 | 22 | this.setDefaultValues( defaultValues ); 23 | 24 | this.setValues( parameters ); 25 | 26 | } 27 | 28 | setupDiffuseColor() { 29 | 30 | const opacityNode = this.opacityNode ? float( this.opacityNode ) : materialOpacity; 31 | 32 | diffuseColor.assign( vec4( directionToColor( transformedNormalView ), opacityNode ) ); 33 | 34 | } 35 | 36 | } 37 | 38 | export default MeshNormalNodeMaterial; 39 | 40 | addNodeMaterial( 'MeshNormalNodeMaterial', MeshNormalNodeMaterial ); 41 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/transpiler/ShaderToyDecoder.js: -------------------------------------------------------------------------------- 1 | import { Return, VariableDeclaration, Accessor } from './AST.js'; 2 | import GLSLDecoder from './GLSLDecoder.js'; 3 | 4 | class ShaderToyDecoder extends GLSLDecoder { 5 | 6 | constructor() { 7 | 8 | super(); 9 | 10 | this.addPolyfill( 'iTime', 'float iTime = timerGlobal();' ); 11 | this.addPolyfill( 'iResolution', 'vec2 iResolution = viewportResolution;' ); 12 | this.addPolyfill( 'fragCoord', 'vec2 fragCoord = vec2( viewportCoordinate.x, viewportResolution.y - viewportCoordinate.y );' ); 13 | 14 | } 15 | 16 | parseFunction() { 17 | 18 | const node = super.parseFunction(); 19 | 20 | if ( node.name === 'mainImage' ) { 21 | 22 | node.params = []; // remove default parameters 23 | node.type = 'vec4'; 24 | node.layout = false; // for now 25 | 26 | const fragColor = new Accessor( 'fragColor' ); 27 | 28 | for ( const subNode of node.body ) { 29 | 30 | if ( subNode.isReturn ) { 31 | 32 | subNode.value = fragColor; 33 | 34 | } 35 | 36 | } 37 | 38 | node.body.unshift( new VariableDeclaration( 'vec4', 'fragColor' ) ); 39 | node.body.push( new Return( fragColor ) ); 40 | 41 | } 42 | 43 | return node; 44 | 45 | } 46 | 47 | } 48 | 49 | export default ShaderToyDecoder; -------------------------------------------------------------------------------- /src/assets/modules/three-addons/shaders/NormalMapShader.js: -------------------------------------------------------------------------------- 1 | import { 2 | Vector2 3 | } from 'three'; 4 | 5 | /** 6 | * Normal map shader 7 | * - compute normals from heightmap 8 | */ 9 | 10 | const NormalMapShader = { 11 | 12 | name: 'NormalMapShader', 13 | 14 | uniforms: { 15 | 16 | 'heightMap': { value: null }, 17 | 'resolution': { value: new Vector2( 512, 512 ) }, 18 | 'scale': { value: new Vector2( 1, 1 ) }, 19 | 'height': { value: 0.05 } 20 | 21 | }, 22 | 23 | vertexShader: /* glsl */` 24 | 25 | varying vec2 vUv; 26 | 27 | void main() { 28 | 29 | vUv = uv; 30 | gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 31 | 32 | }`, 33 | 34 | fragmentShader: /* glsl */` 35 | 36 | uniform float height; 37 | uniform vec2 resolution; 38 | uniform sampler2D heightMap; 39 | 40 | varying vec2 vUv; 41 | 42 | void main() { 43 | 44 | float val = texture2D( heightMap, vUv ).x; 45 | 46 | float valU = texture2D( heightMap, vUv + vec2( 1.0 / resolution.x, 0.0 ) ).x; 47 | float valV = texture2D( heightMap, vUv + vec2( 0.0, 1.0 / resolution.y ) ).x; 48 | 49 | gl_FragColor = vec4( ( 0.5 * normalize( vec3( val - valU, val - valV, height ) ) + 0.5 ), 1.0 ); 50 | 51 | }` 52 | 53 | }; 54 | 55 | export { NormalMapShader }; 56 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/capabilities/WebGPU.js: -------------------------------------------------------------------------------- 1 | if ( window.GPUShaderStage === undefined ) { 2 | 3 | window.GPUShaderStage = { VERTEX: 1, FRAGMENT: 2, COMPUTE: 4 }; 4 | 5 | } 6 | 7 | let isAvailable = false; 8 | 9 | if ( navigator.gpu !== undefined ) { 10 | 11 | const adapter = await navigator.gpu.requestAdapter(); 12 | 13 | if ( adapter !== null ) { 14 | 15 | isAvailable = true; 16 | 17 | } 18 | 19 | } 20 | 21 | class WebGPU { 22 | 23 | static isAvailable() { 24 | 25 | return isAvailable; 26 | 27 | } 28 | 29 | static getErrorMessage() { 30 | 31 | const message = 'Your browser does not support WebGPU yet'; 32 | 33 | const element = document.createElement( 'div' ); 34 | element.id = 'webgpumessage'; 35 | element.style.fontFamily = 'monospace'; 36 | element.style.fontSize = '13px'; 37 | element.style.fontWeight = 'normal'; 38 | element.style.textAlign = 'center'; 39 | element.style.background = '#fff'; 40 | element.style.color = '#000'; 41 | element.style.padding = '1.5em'; 42 | element.style.maxWidth = '400px'; 43 | element.style.margin = '5em auto 0'; 44 | 45 | element.innerHTML = message; 46 | 47 | return element; 48 | 49 | } 50 | 51 | } 52 | 53 | export default WebGPU; 54 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/materials/Materials.js: -------------------------------------------------------------------------------- 1 | // @TODO: We can simplify "export { default as SomeNode, other, exports } from '...'" to just "export * from '...'" if we will use only named exports 2 | 3 | export { default as NodeMaterial, addNodeMaterial, createNodeMaterialFromType } from './NodeMaterial.js'; 4 | export { default as InstancedPointsNodeMaterial } from './InstancedPointsNodeMaterial.js'; 5 | export { default as LineBasicNodeMaterial } from './LineBasicNodeMaterial.js'; 6 | export { default as LineDashedNodeMaterial } from './LineDashedNodeMaterial.js'; 7 | export { default as Line2NodeMaterial } from './Line2NodeMaterial.js'; 8 | export { default as MeshNormalNodeMaterial } from './MeshNormalNodeMaterial.js'; 9 | export { default as MeshBasicNodeMaterial } from './MeshBasicNodeMaterial.js'; 10 | export { default as MeshLambertNodeMaterial } from './MeshLambertNodeMaterial.js'; 11 | export { default as MeshPhongNodeMaterial } from './MeshPhongNodeMaterial.js'; 12 | export { default as MeshStandardNodeMaterial } from './MeshStandardNodeMaterial.js'; 13 | export { default as MeshPhysicalNodeMaterial } from './MeshPhysicalNodeMaterial.js'; 14 | export { default as PointsNodeMaterial } from './PointsNodeMaterial.js'; 15 | export { default as SpriteNodeMaterial } from './SpriteNodeMaterial.js'; 16 | -------------------------------------------------------------------------------- /src/modal/progress/app.js: -------------------------------------------------------------------------------- 1 | import * as util from "../../util.mjs"; 2 | import { V } from "../../util.mjs"; 3 | import * as lib from "../../lib.mjs"; 4 | 5 | import * as core from "../../core.mjs"; 6 | import { PROPERTYCACHE, GLOBALSTATE } from "../../core.mjs"; 7 | 8 | import AppModal from "../app.js"; 9 | 10 | 11 | export default class App extends AppModal { 12 | #ieProgress; 13 | 14 | #ivalue; 15 | 16 | constructor() { 17 | super(); 18 | 19 | this.addHandler("pre-post-setup", async () => { 20 | this.ielem.classList.add("progress"); 21 | 22 | this.ieIconBox.style.display = "none"; 23 | 24 | this.#ieProgress = document.createElement("div"); 25 | this.iinner.appendChild(this.ieProgress); 26 | this.ieProgress.classList.add("progress"); 27 | 28 | this.#ivalue = null; 29 | 30 | this.ivalue = 0; 31 | }); 32 | } 33 | 34 | get ieProgress() { return this.#ieProgress; } 35 | 36 | get ivalue() { return this.#ivalue; } 37 | set ivalue(v) { 38 | v = Math.min(1, Math.max(0, util.ensure(v, "num"))); 39 | if (this.ivalue == v) return; 40 | this.#ivalue = v; 41 | this.ieProgress.style.setProperty("--progress", (100*this.ivalue)+"%"); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/geometries/ConvexGeometry.js: -------------------------------------------------------------------------------- 1 | import { 2 | BufferGeometry, 3 | Float32BufferAttribute 4 | } from 'three'; 5 | import { ConvexHull } from '../math/ConvexHull.js'; 6 | 7 | class ConvexGeometry extends BufferGeometry { 8 | 9 | constructor( points = [] ) { 10 | 11 | super(); 12 | 13 | // buffers 14 | 15 | const vertices = []; 16 | const normals = []; 17 | 18 | const convexHull = new ConvexHull().setFromPoints( points ); 19 | 20 | // generate vertices and normals 21 | 22 | const faces = convexHull.faces; 23 | 24 | for ( let i = 0; i < faces.length; i ++ ) { 25 | 26 | const face = faces[ i ]; 27 | let edge = face.edge; 28 | 29 | // we move along a doubly-connected edge list to access all face points (see HalfEdge docs) 30 | 31 | do { 32 | 33 | const point = edge.head().point; 34 | 35 | vertices.push( point.x, point.y, point.z ); 36 | normals.push( face.normal.x, face.normal.y, face.normal.z ); 37 | 38 | edge = edge.next; 39 | 40 | } while ( edge !== face.edge ); 41 | 42 | } 43 | 44 | // build geometry 45 | 46 | this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); 47 | this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) ); 48 | 49 | } 50 | 51 | } 52 | 53 | export { ConvexGeometry }; 54 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/shaders/KaleidoShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Kaleidoscope Shader 3 | * Radial reflection around center point 4 | * Ported from: http://pixelshaders.com/editor/ 5 | * by Toby Schachman / http://tobyschachman.com/ 6 | * 7 | * sides: number of reflections 8 | * angle: initial angle in radians 9 | */ 10 | 11 | const KaleidoShader = { 12 | 13 | name: 'KaleidoShader', 14 | 15 | uniforms: { 16 | 17 | 'tDiffuse': { value: null }, 18 | 'sides': { value: 6.0 }, 19 | 'angle': { value: 0.0 } 20 | 21 | }, 22 | 23 | vertexShader: /* glsl */` 24 | 25 | varying vec2 vUv; 26 | 27 | void main() { 28 | 29 | vUv = uv; 30 | gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 31 | 32 | }`, 33 | 34 | fragmentShader: /* glsl */` 35 | 36 | uniform sampler2D tDiffuse; 37 | uniform float sides; 38 | uniform float angle; 39 | 40 | varying vec2 vUv; 41 | 42 | void main() { 43 | 44 | vec2 p = vUv - 0.5; 45 | float r = length(p); 46 | float a = atan(p.y, p.x) + angle; 47 | float tau = 2. * 3.1416 ; 48 | a = mod(a, tau/sides); 49 | a = abs(a - tau/sides/2.) ; 50 | p = r * vec2(cos(a), sin(a)); 51 | vec4 color = texture2D(tDiffuse, p + 0.5); 52 | gl_FragColor = color; 53 | 54 | }` 55 | 56 | }; 57 | 58 | export { KaleidoShader }; 59 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/lighting/LightNode.js: -------------------------------------------------------------------------------- 1 | import Node, { addNodeClass } from '../core/Node.js'; 2 | import { nodeProxy } from '../shadernode/ShaderNode.js'; 3 | import { objectPosition } from '../accessors/Object3DNode.js'; 4 | import { cameraViewMatrix } from '../accessors/CameraNode.js'; 5 | 6 | class LightNode extends Node { 7 | 8 | constructor( scope = LightNode.TARGET_DIRECTION, light = null ) { 9 | 10 | super(); 11 | 12 | this.scope = scope; 13 | this.light = light; 14 | 15 | } 16 | 17 | setup() { 18 | 19 | const { scope, light } = this; 20 | 21 | let output = null; 22 | 23 | if ( scope === LightNode.TARGET_DIRECTION ) { 24 | 25 | output = cameraViewMatrix.transformDirection( objectPosition( light ).sub( objectPosition( light.target ) ) ); 26 | 27 | } 28 | 29 | return output; 30 | 31 | } 32 | 33 | serialize( data ) { 34 | 35 | super.serialize( data ); 36 | 37 | data.scope = this.scope; 38 | 39 | } 40 | 41 | deserialize( data ) { 42 | 43 | super.deserialize( data ); 44 | 45 | this.scope = data.scope; 46 | 47 | } 48 | 49 | } 50 | 51 | LightNode.TARGET_DIRECTION = 'targetDirection'; 52 | 53 | export default LightNode; 54 | 55 | export const lightTargetDirection = nodeProxy( LightNode, LightNode.TARGET_DIRECTION ); 56 | 57 | addNodeClass( 'LightNode', LightNode ); 58 | -------------------------------------------------------------------------------- /docs/panel/tabs/LOGGER.md: -------------------------------------------------------------------------------- 1 | ← Back 2 | 3 | # Logger Tab 4 | 5 | Cloud logging system for instant and community sharing of logs for nearly instantaneous debugging. 6 | 7 | > [!NOTE] 8 | > This tab only functions when there is a dedicated server. Currently, there is no way to set one up. 9 | 10 | ## Navigation 11 | 12 | ### Top Status Bar 13 | Should show current state of Logger's server connection. Clicking on the server address opens the url. Clicking the + button will allow you to select a file to add. 14 | 15 | ### Main Log List 16 | Lists available logs on the server and on your client. To download logs from the server, click the download button on the listed log. To open the log, click the open button on the listed log. For a more extensive menu, right click the listed log to open the menu. 17 | Listed logs have a few states. 18 | 19 | | State | Meaning | Appearance | 20 | | ------------ | --------------------------------------- | ---------------------------- | 21 | | `default` | Exists on the server, not downloaded | Only has download button | 22 | | `downloaded` | Exists on the server, downloaded | Has download and open button | 23 | | `deleted` | Doesn't exist on the server, downloaded | Only has open button, red | 24 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/objects/QuadMesh.js: -------------------------------------------------------------------------------- 1 | import { BufferGeometry, Float32BufferAttribute, Mesh, OrthographicCamera } from 'three'; 2 | 3 | // Helper for passes that need to fill the viewport with a single quad. 4 | 5 | const _camera = new OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); 6 | 7 | // https://github.com/mrdoob/three.js/pull/21358 8 | 9 | class QuadGeometry extends BufferGeometry { 10 | 11 | constructor( flipY = false ) { 12 | 13 | super(); 14 | 15 | const uv = flipY === false ? [ 0, - 1, 0, 1, 2, 1 ] : [ 0, 2, 0, 0, 2, 0 ]; 16 | 17 | this.setAttribute( 'position', new Float32BufferAttribute( [ - 1, 3, 0, - 1, - 1, 0, 3, - 1, 0 ], 3 ) ); 18 | this.setAttribute( 'uv', new Float32BufferAttribute( uv, 2 ) ); 19 | 20 | } 21 | 22 | } 23 | 24 | const _geometry = new QuadGeometry(); 25 | 26 | class QuadMesh { 27 | 28 | constructor( material = null ) { 29 | 30 | this._mesh = new Mesh( _geometry, material ); 31 | 32 | } 33 | 34 | dispose() { 35 | 36 | this._mesh.geometry.dispose(); 37 | 38 | } 39 | 40 | render( renderer ) { 41 | 42 | renderer.render( this._mesh, _camera ); 43 | 44 | } 45 | 46 | get material() { 47 | 48 | return this._mesh.material; 49 | 50 | } 51 | 52 | set material( value ) { 53 | 54 | this._mesh.material = value; 55 | 56 | } 57 | 58 | } 59 | 60 | export default QuadMesh; 61 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/renderers/webgl-legacy/nodes/WebGLNodes.js: -------------------------------------------------------------------------------- 1 | import { WebGLNodeBuilder } from './WebGLNodeBuilder.js'; 2 | import { NodeFrame } from '../../../nodes/Nodes.js'; 3 | 4 | import { Material } from 'three'; 5 | 6 | const builders = new WeakMap(); 7 | export const nodeFrame = new NodeFrame(); 8 | 9 | Material.prototype.onBuild = function ( object, parameters, renderer ) { 10 | 11 | const material = this; 12 | 13 | if ( material.isNodeMaterial === true ) { 14 | 15 | builders.set( material, new WebGLNodeBuilder( object, renderer, parameters, material ).build() ); 16 | 17 | } 18 | 19 | }; 20 | 21 | Material.prototype.onBeforeRender = function ( renderer, scene, camera, geometry, object ) { 22 | 23 | const nodeBuilder = builders.get( this ); 24 | 25 | if ( nodeBuilder !== undefined ) { 26 | 27 | nodeFrame.material = this; 28 | nodeFrame.camera = camera; 29 | nodeFrame.object = object; 30 | nodeFrame.renderer = renderer; 31 | 32 | const updateNodes = nodeBuilder.updateNodes; 33 | 34 | if ( updateNodes.length > 0 ) { 35 | 36 | // force refresh material uniforms 37 | renderer.state.useProgram( null ); 38 | 39 | //this.uniformsNeedUpdate = true; 40 | 41 | for ( const node of updateNodes ) { 42 | 43 | nodeFrame.updateNode( node ); 44 | 45 | } 46 | 47 | } 48 | 49 | } 50 | 51 | }; 52 | -------------------------------------------------------------------------------- /src/assets/modules/highlight-light.min.css: -------------------------------------------------------------------------------- 1 | pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}/*! 2 | Theme: GitHub 3 | Description: Light theme as seen on github.com 4 | Author: github.com 5 | Maintainer: @Hirse 6 | Updated: 2021-05-15 7 | 8 | Outdated base version: https://github.com/primer/github-syntax-light 9 | Current colors taken from GitHub's CSS 10 | */.hljs{color:#24292e;background:#fff}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_{color:#d73a49}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#6f42c1}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#005cc5}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#032f62}.hljs-built_in,.hljs-symbol{color:#e36209}.hljs-code,.hljs-comment,.hljs-formula{color:#6a737d}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#22863a}.hljs-subst{color:#24292e}.hljs-section{color:#005cc5;font-weight:700}.hljs-bullet{color:#735c0f}.hljs-emphasis{color:#24292e;font-style:italic}.hljs-strong{color:#24292e;font-weight:700}.hljs-addition{color:#22863a;background-color:#f0fff4}.hljs-deletion{color:#b31d28;background-color:#ffeef0} -------------------------------------------------------------------------------- /src/assets/modules/highlight-dark.min.css: -------------------------------------------------------------------------------- 1 | pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}/*! 2 | Theme: GitHub Dark 3 | Description: Dark theme as seen on github.com 4 | Author: github.com 5 | Maintainer: @Hirse 6 | Updated: 2021-05-15 7 | 8 | Outdated base version: https://github.com/primer/github-syntax-dark 9 | Current colors taken from GitHub's CSS 10 | */.hljs{color:#c9d1d9;background:#0d1117}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_{color:#ff7b72}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#d2a8ff}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#79c0ff}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#a5d6ff}.hljs-built_in,.hljs-symbol{color:#ffa657}.hljs-code,.hljs-comment,.hljs-formula{color:#8b949e}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#7ee787}.hljs-subst{color:#c9d1d9}.hljs-section{color:#1f6feb;font-weight:700}.hljs-bullet{color:#f2cc60}.hljs-emphasis{color:#c9d1d9;font-style:italic}.hljs-strong{color:#c9d1d9;font-weight:700}.hljs-addition{color:#aff5b4;background-color:#033a16}.hljs-deletion{color:#ffdcd7;background-color:#67060c} -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/utils/ConvertNode.js: -------------------------------------------------------------------------------- 1 | import Node, { addNodeClass } from '../core/Node.js'; 2 | 3 | class ConvertNode extends Node { 4 | 5 | constructor( node, convertTo ) { 6 | 7 | super(); 8 | 9 | this.node = node; 10 | this.convertTo = convertTo; 11 | 12 | } 13 | 14 | getNodeType( builder ) { 15 | 16 | const requestType = this.node.getNodeType( builder ); 17 | 18 | let convertTo = null; 19 | 20 | for ( const overloadingType of this.convertTo.split( '|' ) ) { 21 | 22 | if ( convertTo === null || builder.getTypeLength( requestType ) === builder.getTypeLength( overloadingType ) ) { 23 | 24 | convertTo = overloadingType; 25 | 26 | } 27 | 28 | } 29 | 30 | return convertTo; 31 | 32 | } 33 | 34 | serialize( data ) { 35 | 36 | super.serialize( data ); 37 | 38 | data.convertTo = this.convertTo; 39 | 40 | } 41 | 42 | deserialize( data ) { 43 | 44 | super.deserialize( data ); 45 | 46 | this.convertTo = data.convertTo; 47 | 48 | } 49 | 50 | generate( builder, output ) { 51 | 52 | const node = this.node; 53 | const type = this.getNodeType( builder ); 54 | 55 | const snippet = node.build( builder, type ); 56 | 57 | return builder.format( snippet, type, output ); 58 | 59 | } 60 | 61 | } 62 | 63 | export default ConvertNode; 64 | 65 | addNodeClass( 'ConvertNode', ConvertNode ); 66 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/shaders/BrightnessContrastShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Brightness and contrast adjustment 3 | * https://github.com/evanw/glfx.js 4 | * brightness: -1 to 1 (-1 is solid black, 0 is no change, and 1 is solid white) 5 | * contrast: -1 to 1 (-1 is solid gray, 0 is no change, and 1 is maximum contrast) 6 | */ 7 | 8 | const BrightnessContrastShader = { 9 | 10 | name: 'BrightnessContrastShader', 11 | 12 | uniforms: { 13 | 14 | 'tDiffuse': { value: null }, 15 | 'brightness': { value: 0 }, 16 | 'contrast': { value: 0 } 17 | 18 | }, 19 | 20 | vertexShader: /* glsl */` 21 | 22 | varying vec2 vUv; 23 | 24 | void main() { 25 | 26 | vUv = uv; 27 | 28 | gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 29 | 30 | }`, 31 | 32 | fragmentShader: /* glsl */` 33 | 34 | uniform sampler2D tDiffuse; 35 | uniform float brightness; 36 | uniform float contrast; 37 | 38 | varying vec2 vUv; 39 | 40 | void main() { 41 | 42 | gl_FragColor = texture2D( tDiffuse, vUv ); 43 | 44 | gl_FragColor.rgb += brightness; 45 | 46 | if (contrast > 0.0) { 47 | gl_FragColor.rgb = (gl_FragColor.rgb - 0.5) / (1.0 - contrast) + 0.5; 48 | } else { 49 | gl_FragColor.rgb = (gl_FragColor.rgb - 0.5) * (1.0 + contrast) + 0.5; 50 | } 51 | 52 | }` 53 | 54 | }; 55 | 56 | export { BrightnessContrastShader }; 57 | -------------------------------------------------------------------------------- /src/modal/alert/app.js: -------------------------------------------------------------------------------- 1 | import * as util from "../../util.mjs"; 2 | import { V } from "../../util.mjs"; 3 | import * as lib from "../../lib.mjs"; 4 | 5 | import * as core from "../../core.mjs"; 6 | import { PROPERTYCACHE, GLOBALSTATE } from "../../core.mjs"; 7 | 8 | import AppModal from "../app.js"; 9 | 10 | 11 | export default class App extends AppModal { 12 | #ieButton; 13 | 14 | constructor() { 15 | super(); 16 | 17 | this.addHandler("pre-post-setup", async () => { 18 | this.ielem.classList.add("alert"); 19 | 20 | this.#ieButton = document.createElement("button"); 21 | this.iinner.appendChild(this.ieButton); 22 | this.ieButton.classList.add("special"); 23 | 24 | this.ieButton.addEventListener("click", async e => { 25 | e.stopPropagation(); 26 | await this.doModify({ 27 | cmds: ["button"], 28 | }); 29 | }); 30 | 31 | this.iicon = "alert-circle"; 32 | this.ibutton = "OK"; 33 | }); 34 | this.addHandler("post-setup", async () => { 35 | this.ieButton.focus(); 36 | }); 37 | } 38 | 39 | get ieButton() { return this.#ieButton; } 40 | 41 | get ibutton() { return this.ieButton.textContent; } 42 | set ibutton(v) { this.ieButton.textContent = v; } 43 | } 44 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/core/VarNode.js: -------------------------------------------------------------------------------- 1 | import Node, { addNodeClass } from './Node.js'; 2 | import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js'; 3 | 4 | class VarNode extends Node { 5 | 6 | constructor( node, name = null ) { 7 | 8 | super(); 9 | 10 | this.node = node; 11 | this.name = name; 12 | 13 | this.isVarNode = true; 14 | 15 | } 16 | 17 | isGlobal() { 18 | 19 | return true; 20 | 21 | } 22 | 23 | getHash( builder ) { 24 | 25 | return this.name || super.getHash( builder ); 26 | 27 | } 28 | 29 | getNodeType( builder ) { 30 | 31 | return this.node.getNodeType( builder ); 32 | 33 | } 34 | 35 | generate( builder ) { 36 | 37 | const { node, name } = this; 38 | 39 | const nodeVar = builder.getVarFromNode( this, name, builder.getVectorType( this.getNodeType( builder ) ) ); 40 | 41 | const propertyName = builder.getPropertyName( nodeVar ); 42 | 43 | const snippet = node.build( builder, nodeVar.type ); 44 | 45 | builder.addLineFlowCode( `${propertyName} = ${snippet}` ); 46 | 47 | return propertyName; 48 | 49 | } 50 | 51 | } 52 | 53 | export default VarNode; 54 | 55 | export const temp = nodeProxy( VarNode ); 56 | 57 | addNodeElement( 'temp', temp ); // @TODO: Will be removed in the future 58 | addNodeElement( 'toVar', ( ...params ) => temp( ...params ).append() ); 59 | 60 | addNodeClass( 'VarNode', VarNode ); 61 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/shaders/RGBShiftShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * RGB Shift Shader 3 | * Shifts red and blue channels from center in opposite directions 4 | * Ported from https://web.archive.org/web/20090820185047/http://kriss.cx/tom/2009/05/rgb-shift/ 5 | * by Tom Butterworth / https://web.archive.org/web/20090810054752/http://kriss.cx/tom/ 6 | * 7 | * amount: shift distance (1 is width of input) 8 | * angle: shift angle in radians 9 | */ 10 | 11 | const RGBShiftShader = { 12 | 13 | name: 'RGBShiftShader', 14 | 15 | uniforms: { 16 | 17 | 'tDiffuse': { value: null }, 18 | 'amount': { value: 0.005 }, 19 | 'angle': { value: 0.0 } 20 | 21 | }, 22 | 23 | vertexShader: /* glsl */` 24 | 25 | varying vec2 vUv; 26 | 27 | void main() { 28 | 29 | vUv = uv; 30 | gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 31 | 32 | }`, 33 | 34 | fragmentShader: /* glsl */` 35 | 36 | uniform sampler2D tDiffuse; 37 | uniform float amount; 38 | uniform float angle; 39 | 40 | varying vec2 vUv; 41 | 42 | void main() { 43 | 44 | vec2 offset = amount * vec2( cos(angle), sin(angle)); 45 | vec4 cr = texture2D(tDiffuse, vUv + offset); 46 | vec4 cga = texture2D(tDiffuse, vUv); 47 | vec4 cb = texture2D(tDiffuse, vUv - offset); 48 | gl_FragColor = vec4(cr.r, cga.g, cb.b, cga.a); 49 | 50 | }` 51 | 52 | }; 53 | 54 | export { RGBShiftShader }; 55 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/utils/PackingNode.js: -------------------------------------------------------------------------------- 1 | import TempNode from '../core/TempNode.js'; 2 | import { addNodeClass } from '../core/Node.js'; 3 | import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js'; 4 | 5 | class PackingNode extends TempNode { 6 | 7 | constructor( scope, node ) { 8 | 9 | super(); 10 | 11 | this.scope = scope; 12 | this.node = node; 13 | 14 | } 15 | 16 | getNodeType( builder ) { 17 | 18 | return this.node.getNodeType( builder ); 19 | 20 | } 21 | 22 | setup() { 23 | 24 | const { scope, node } = this; 25 | 26 | let result = null; 27 | 28 | if ( scope === PackingNode.DIRECTION_TO_COLOR ) { 29 | 30 | result = node.mul( 0.5 ).add( 0.5 ); 31 | 32 | } else if ( scope === PackingNode.COLOR_TO_DIRECTION ) { 33 | 34 | result = node.mul( 2.0 ).sub( 1 ); 35 | 36 | } 37 | 38 | return result; 39 | 40 | } 41 | 42 | } 43 | 44 | PackingNode.DIRECTION_TO_COLOR = 'directionToColor'; 45 | PackingNode.COLOR_TO_DIRECTION = 'colorToDirection'; 46 | 47 | export default PackingNode; 48 | 49 | export const directionToColor = nodeProxy( PackingNode, PackingNode.DIRECTION_TO_COLOR ); 50 | export const colorToDirection = nodeProxy( PackingNode, PackingNode.COLOR_TO_DIRECTION ); 51 | 52 | addNodeElement( 'directionToColor', directionToColor ); 53 | addNodeElement( 'colorToDirection', colorToDirection ); 54 | 55 | addNodeClass( 'PackingNode', PackingNode ); 56 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/accessors/MaterialReferenceNode.js: -------------------------------------------------------------------------------- 1 | import ReferenceNode from './ReferenceNode.js'; 2 | //import { renderGroup } from '../core/UniformGroupNode.js'; 3 | //import { NodeUpdateType } from '../core/constants.js'; 4 | import { addNodeClass } from '../core/Node.js'; 5 | import { nodeObject } from '../shadernode/ShaderNode.js'; 6 | 7 | class MaterialReferenceNode extends ReferenceNode { 8 | 9 | constructor( property, inputType, material = null ) { 10 | 11 | super( property, inputType, material ); 12 | 13 | this.material = material; 14 | 15 | //this.updateType = NodeUpdateType.RENDER; 16 | 17 | } 18 | 19 | /*setNodeType( node ) { 20 | 21 | super.setNodeType( node ); 22 | 23 | this.node.groupNode = renderGroup; 24 | 25 | }*/ 26 | 27 | updateReference( frame ) { 28 | 29 | this.reference = this.material !== null ? this.material : frame.material; 30 | 31 | return this.reference; 32 | 33 | } 34 | 35 | setup( builder ) { 36 | 37 | const material = this.material !== null ? this.material : builder.material; 38 | 39 | this.node.value = material[ this.property ]; 40 | 41 | return super.setup( builder ); 42 | 43 | } 44 | 45 | } 46 | 47 | export default MaterialReferenceNode; 48 | 49 | export const materialReference = ( name, type, material ) => nodeObject( new MaterialReferenceNode( name, type, material ) ); 50 | 51 | addNodeClass( 'MaterialReferenceNode', MaterialReferenceNode ); 52 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/core/ContextNode.js: -------------------------------------------------------------------------------- 1 | import Node, { addNodeClass } from './Node.js'; 2 | import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js'; 3 | 4 | class ContextNode extends Node { 5 | 6 | constructor( node, context = {} ) { 7 | 8 | super(); 9 | 10 | this.isContextNode = true; 11 | 12 | this.node = node; 13 | this.context = context; 14 | 15 | } 16 | 17 | getNodeType( builder ) { 18 | 19 | return this.node.getNodeType( builder ); 20 | 21 | } 22 | 23 | setup( builder ) { 24 | 25 | const previousContext = builder.getContext(); 26 | 27 | builder.setContext( { ...builder.context, ...this.context } ); 28 | 29 | const node = this.node.build( builder ); 30 | 31 | builder.setContext( previousContext ); 32 | 33 | return node; 34 | 35 | } 36 | 37 | generate( builder, output ) { 38 | 39 | const previousContext = builder.getContext(); 40 | 41 | builder.setContext( { ...builder.context, ...this.context } ); 42 | 43 | const snippet = this.node.build( builder, output ); 44 | 45 | builder.setContext( previousContext ); 46 | 47 | return snippet; 48 | 49 | } 50 | 51 | } 52 | 53 | export default ContextNode; 54 | 55 | export const context = nodeProxy( ContextNode ); 56 | export const label = ( node, name ) => context( node, { label: name } ); 57 | 58 | addNodeElement( 'context', context ); 59 | addNodeElement( 'label', label ); 60 | 61 | addNodeClass( 'ContextNode', ContextNode ); 62 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/effects/StereoEffect.js: -------------------------------------------------------------------------------- 1 | import { 2 | StereoCamera, 3 | Vector2 4 | } from 'three'; 5 | 6 | class StereoEffect { 7 | 8 | constructor( renderer ) { 9 | 10 | const _stereo = new StereoCamera(); 11 | _stereo.aspect = 0.5; 12 | const size = new Vector2(); 13 | 14 | this.setEyeSeparation = function ( eyeSep ) { 15 | 16 | _stereo.eyeSep = eyeSep; 17 | 18 | }; 19 | 20 | this.setSize = function ( width, height ) { 21 | 22 | renderer.setSize( width, height ); 23 | 24 | }; 25 | 26 | this.render = function ( scene, camera ) { 27 | 28 | if ( scene.matrixWorldAutoUpdate === true ) scene.updateMatrixWorld(); 29 | 30 | if ( camera.parent === null && camera.matrixWorldAutoUpdate === true ) camera.updateMatrixWorld(); 31 | 32 | _stereo.update( camera ); 33 | 34 | renderer.getSize( size ); 35 | 36 | if ( renderer.autoClear ) renderer.clear(); 37 | renderer.setScissorTest( true ); 38 | 39 | renderer.setScissor( 0, 0, size.width / 2, size.height ); 40 | renderer.setViewport( 0, 0, size.width / 2, size.height ); 41 | renderer.render( scene, _stereo.cameraL ); 42 | 43 | renderer.setScissor( size.width / 2, 0, size.width / 2, size.height ); 44 | renderer.setViewport( size.width / 2, 0, size.width / 2, size.height ); 45 | renderer.render( scene, _stereo.cameraR ); 46 | 47 | renderer.setScissorTest( false ); 48 | 49 | }; 50 | 51 | } 52 | 53 | } 54 | 55 | export { StereoEffect }; 56 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/loaders/NodeObjectLoader.js: -------------------------------------------------------------------------------- 1 | import NodeLoader from './NodeLoader.js'; 2 | import NodeMaterialLoader from './NodeMaterialLoader.js'; 3 | import { ObjectLoader } from 'three'; 4 | 5 | class NodeObjectLoader extends ObjectLoader { 6 | 7 | constructor( manager ) { 8 | 9 | super( manager ); 10 | 11 | this._nodesJSON = null; 12 | 13 | } 14 | 15 | parse( json, onLoad ) { 16 | 17 | this._nodesJSON = json.nodes; 18 | 19 | const data = super.parse( json, onLoad ); 20 | 21 | this._nodesJSON = null; // dispose 22 | 23 | return data; 24 | 25 | } 26 | 27 | parseNodes( json, textures ) { 28 | 29 | if ( json !== undefined ) { 30 | 31 | const loader = new NodeLoader(); 32 | loader.setTextures( textures ); 33 | 34 | return loader.parseNodes( json ); 35 | 36 | } 37 | 38 | return {}; 39 | 40 | } 41 | 42 | parseMaterials( json, textures ) { 43 | 44 | const materials = {}; 45 | 46 | if ( json !== undefined ) { 47 | 48 | const nodes = this.parseNodes( this._nodesJSON, textures ); 49 | 50 | const loader = new NodeMaterialLoader(); 51 | loader.setTextures( textures ); 52 | loader.setNodes( nodes ); 53 | 54 | for ( let i = 0, l = json.length; i < l; i ++ ) { 55 | 56 | const data = json[ i ]; 57 | 58 | materials[ data.uuid ] = loader.parse( data ); 59 | 60 | } 61 | 62 | } 63 | 64 | return materials; 65 | 66 | } 67 | 68 | } 69 | 70 | export default NodeObjectLoader; 71 | -------------------------------------------------------------------------------- /src/pythontk/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 14 | 19 | 20 | 21 |
22 |
23 |
24 |
PeninsulaPortal
25 |
Python Toolkit
26 | 30 |
31 |
32 |
33 |
34 | 37 |
38 |
39 |
40 |
41 |
42 | 45 |
46 |
47 | 48 | -------------------------------------------------------------------------------- /docs/panel/tabs/VIDSYNC.md: -------------------------------------------------------------------------------- 1 | ← Back 2 | 3 | # Video Sync Tab 4 | 5 | Syncs a video file with the current log. 6 | 7 | ## Navigation 8 | 9 | ### Main Display 10 | Simply the video playback displayed. 11 | 12 | ### Bottom Menu 13 | Below the main display is the bottom menu. It consists of the videos on the left and the editor on the right. 14 | 15 | #### Video List 16 | Click on the Youtube icon to automatically upload a video from Youtube. Click on the file icon to load in a video from your personal computer. Click on ... to access some options, like removing the video or renaming it. 17 | 18 | #### Editor 19 | Drag the blue bar around relative to the grey bar, which represents the entire log. Below are some options: 20 | - **Pencil** — Enter a custom timestamp, such that the beginning of the video is that many seconds after the start of the log (`t0`). 21 | - **←** — Alighs the video to the beginning of the log. Essentially, the beginning of the log is the video. 22 | - **←Skip** — Skips the playback position to the beginning of the video. 23 | - **Action** — Triggers the same action as the action button on the bottom navigation of the entire application. 24 | - **→Skip** — Skips the playback position to the end of the video. 25 | - **→** — Aligns the video to the end of the log. Essentially, the end of the log is the end of the video. 26 | - **Lock** — Prevents editing of this specific video, so that you cannot accidentally edit anything. 27 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/misc/MorphAnimMesh.js: -------------------------------------------------------------------------------- 1 | import { 2 | AnimationClip, 3 | AnimationMixer, 4 | Mesh 5 | } from 'three'; 6 | 7 | class MorphAnimMesh extends Mesh { 8 | 9 | constructor( geometry, material ) { 10 | 11 | super( geometry, material ); 12 | 13 | this.type = 'MorphAnimMesh'; 14 | 15 | this.mixer = new AnimationMixer( this ); 16 | this.activeAction = null; 17 | 18 | } 19 | 20 | setDirectionForward() { 21 | 22 | this.mixer.timeScale = 1.0; 23 | 24 | } 25 | 26 | setDirectionBackward() { 27 | 28 | this.mixer.timeScale = - 1.0; 29 | 30 | } 31 | 32 | playAnimation( label, fps ) { 33 | 34 | if ( this.activeAction ) { 35 | 36 | this.activeAction.stop(); 37 | this.activeAction = null; 38 | 39 | } 40 | 41 | const clip = AnimationClip.findByName( this, label ); 42 | 43 | if ( clip ) { 44 | 45 | const action = this.mixer.clipAction( clip ); 46 | action.timeScale = ( clip.tracks.length * fps ) / clip.duration; 47 | this.activeAction = action.play(); 48 | 49 | } else { 50 | 51 | throw new Error( 'THREE.MorphAnimMesh: animations[' + label + '] undefined in .playAnimation()' ); 52 | 53 | } 54 | 55 | } 56 | 57 | updateAnimation( delta ) { 58 | 59 | this.mixer.update( delta ); 60 | 61 | } 62 | 63 | copy( source, recursive ) { 64 | 65 | super.copy( source, recursive ); 66 | 67 | this.mixer = new AnimationMixer( this ); 68 | 69 | return this; 70 | 71 | } 72 | 73 | } 74 | 75 | export { MorphAnimMesh }; 76 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/accessors/SceneNode.js: -------------------------------------------------------------------------------- 1 | import Node from '../core/Node.js'; 2 | import { addNodeClass } from '../core/Node.js'; 3 | import { nodeImmutable } from '../shadernode/ShaderNode.js'; 4 | import { reference } from './ReferenceNode.js'; 5 | 6 | class SceneNode extends Node { 7 | 8 | constructor( scope = SceneNode.BACKGROUND_BLURRINESS, scene = null ) { 9 | 10 | super(); 11 | 12 | this.scope = scope; 13 | this.scene = scene; 14 | 15 | } 16 | 17 | setup( builder ) { 18 | 19 | const scope = this.scope; 20 | const scene = this.scene !== null ? this.scene : builder.scene; 21 | 22 | let output; 23 | 24 | if ( scope === SceneNode.BACKGROUND_BLURRINESS ) { 25 | 26 | output = reference( 'backgroundBlurriness', 'float', scene ); 27 | 28 | } else if ( scope === SceneNode.BACKGROUND_INTENSITY ) { 29 | 30 | output = reference( 'backgroundIntensity', 'float', scene ); 31 | 32 | } else { 33 | 34 | console.error( 'THREE.SceneNode: Unknown scope:', scope ); 35 | 36 | } 37 | 38 | return output; 39 | 40 | } 41 | 42 | } 43 | 44 | SceneNode.BACKGROUND_BLURRINESS = 'backgroundBlurriness'; 45 | SceneNode.BACKGROUND_INTENSITY = 'backgroundIntensity'; 46 | 47 | export default SceneNode; 48 | 49 | export const backgroundBlurriness = nodeImmutable( SceneNode, SceneNode.BACKGROUND_BLURRINESS ); 50 | export const backgroundIntensity = nodeImmutable( SceneNode, SceneNode.BACKGROUND_INTENSITY ); 51 | 52 | addNodeClass( 'SceneNode', SceneNode ); 53 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/misc/Gyroscope.js: -------------------------------------------------------------------------------- 1 | import { 2 | Object3D, 3 | Quaternion, 4 | Vector3 5 | } from 'three'; 6 | 7 | const _translationObject = new Vector3(); 8 | const _quaternionObject = new Quaternion(); 9 | const _scaleObject = new Vector3(); 10 | 11 | const _translationWorld = new Vector3(); 12 | const _quaternionWorld = new Quaternion(); 13 | const _scaleWorld = new Vector3(); 14 | 15 | class Gyroscope extends Object3D { 16 | 17 | constructor() { 18 | 19 | super(); 20 | 21 | } 22 | 23 | updateMatrixWorld( force ) { 24 | 25 | this.matrixAutoUpdate && this.updateMatrix(); 26 | 27 | // update matrixWorld 28 | 29 | if ( this.matrixWorldNeedsUpdate || force ) { 30 | 31 | if ( this.parent !== null ) { 32 | 33 | this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix ); 34 | 35 | this.matrixWorld.decompose( _translationWorld, _quaternionWorld, _scaleWorld ); 36 | this.matrix.decompose( _translationObject, _quaternionObject, _scaleObject ); 37 | 38 | this.matrixWorld.compose( _translationWorld, _quaternionObject, _scaleWorld ); 39 | 40 | 41 | } else { 42 | 43 | this.matrixWorld.copy( this.matrix ); 44 | 45 | } 46 | 47 | 48 | this.matrixWorldNeedsUpdate = false; 49 | 50 | force = true; 51 | 52 | } 53 | 54 | // update children 55 | 56 | for ( let i = 0, l = this.children.length; i < l; i ++ ) { 57 | 58 | this.children[ i ].updateMatrixWorld( force ); 59 | 60 | } 61 | 62 | } 63 | 64 | } 65 | 66 | export { Gyroscope }; 67 | -------------------------------------------------------------------------------- /src/pit/style.css: -------------------------------------------------------------------------------- 1 | #titlebar { 2 | border-bottom: none; 3 | background-color: transparent; 4 | } 5 | 6 | body { 7 | background-color: var(--v1); 8 | } 9 | 10 | #mount { 11 | top: 0px; 12 | 13 | height: 100%; 14 | max-height: 100%; 15 | } 16 | #PAGE { 17 | width: 100%; 18 | height: 100%; 19 | overflow: hidden; 20 | 21 | display: flex; 22 | flex-direction: column; 23 | flex-wrap: nowrap; 24 | justify-content: center; 25 | align-items: center; 26 | align-content: center; 27 | 28 | background: var(--gradient); 29 | } 30 | #PAGE > canvas { 31 | z-index: -1; 32 | 33 | position: absolute; 34 | top: 0%; 35 | left: 0%; 36 | } 37 | #PAGE > .content { 38 | display: flex; 39 | flex-direction: column; 40 | flex-wrap: nowrap; 41 | justify-content: center; 42 | align-items: center; 43 | align-content: center; 44 | gap: 10px; 45 | } 46 | #PAGE > .content > * { 47 | color: var(--v6); 48 | } 49 | #PAGE > .content > :last-child { 50 | padding-bottom: 40vh; 51 | } 52 | #PAGE > .content > .title { 53 | display: flex; 54 | flex-direction: row; 55 | flex-wrap: nowrap; 56 | justify-content: flex-start; 57 | align-items: center; 58 | align-content: center; 59 | 60 | color: var(--v8); 61 | 62 | font-size: min(5vw, 5vh); 63 | font-weight: 700; 64 | } 65 | #PAGE > .content > .title > :first-child { 66 | color: var(--a); 67 | } 68 | #PAGE > .content > .subtitle { 69 | font-size: min(2.5vw, 2.5vh); 70 | } 71 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/shaders/BleachBypassShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Bleach bypass shader [http://en.wikipedia.org/wiki/Bleach_bypass] 3 | * - based on Nvidia example 4 | * http://developer.download.nvidia.com/shaderlibrary/webpages/shader_library.html#post_bleach_bypass 5 | */ 6 | 7 | const BleachBypassShader = { 8 | 9 | name: 'BleachBypassShader', 10 | 11 | uniforms: { 12 | 13 | 'tDiffuse': { value: null }, 14 | 'opacity': { value: 1.0 } 15 | 16 | }, 17 | 18 | vertexShader: /* glsl */` 19 | 20 | varying vec2 vUv; 21 | 22 | void main() { 23 | 24 | vUv = uv; 25 | gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 26 | 27 | }`, 28 | 29 | fragmentShader: /* glsl */` 30 | 31 | uniform float opacity; 32 | 33 | uniform sampler2D tDiffuse; 34 | 35 | varying vec2 vUv; 36 | 37 | void main() { 38 | 39 | vec4 base = texture2D( tDiffuse, vUv ); 40 | 41 | vec3 lumCoeff = vec3( 0.25, 0.65, 0.1 ); 42 | float lum = dot( lumCoeff, base.rgb ); 43 | vec3 blend = vec3( lum ); 44 | 45 | float L = min( 1.0, max( 0.0, 10.0 * ( lum - 0.45 ) ) ); 46 | 47 | vec3 result1 = 2.0 * base.rgb * blend; 48 | vec3 result2 = 1.0 - 2.0 * ( 1.0 - blend ) * ( 1.0 - base.rgb ); 49 | 50 | vec3 newColor = mix( result1, result2, L ); 51 | 52 | float A2 = opacity * base.a; 53 | vec3 mixRGB = A2 * newColor.rgb; 54 | mixRGB += ( ( 1.0 - A2 ) * base.rgb ); 55 | 56 | gl_FragColor = vec4( mixRGB, base.a ); 57 | 58 | }` 59 | 60 | }; 61 | 62 | export { BleachBypassShader }; 63 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/shaders/LuminosityHighPassShader.js: -------------------------------------------------------------------------------- 1 | import { 2 | Color 3 | } from 'three'; 4 | 5 | /** 6 | * Luminosity 7 | * http://en.wikipedia.org/wiki/Luminosity 8 | */ 9 | 10 | const LuminosityHighPassShader = { 11 | 12 | name: 'LuminosityHighPassShader', 13 | 14 | shaderID: 'luminosityHighPass', 15 | 16 | uniforms: { 17 | 18 | 'tDiffuse': { value: null }, 19 | 'luminosityThreshold': { value: 1.0 }, 20 | 'smoothWidth': { value: 1.0 }, 21 | 'defaultColor': { value: new Color( 0x000000 ) }, 22 | 'defaultOpacity': { value: 0.0 } 23 | 24 | }, 25 | 26 | vertexShader: /* glsl */` 27 | 28 | varying vec2 vUv; 29 | 30 | void main() { 31 | 32 | vUv = uv; 33 | 34 | gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 35 | 36 | }`, 37 | 38 | fragmentShader: /* glsl */` 39 | 40 | uniform sampler2D tDiffuse; 41 | uniform vec3 defaultColor; 42 | uniform float defaultOpacity; 43 | uniform float luminosityThreshold; 44 | uniform float smoothWidth; 45 | 46 | varying vec2 vUv; 47 | 48 | void main() { 49 | 50 | vec4 texel = texture2D( tDiffuse, vUv ); 51 | 52 | vec3 luma = vec3( 0.299, 0.587, 0.114 ); 53 | 54 | float v = dot( texel.xyz, luma ); 55 | 56 | vec4 outputColor = vec4( defaultColor.rgb, defaultOpacity ); 57 | 58 | float alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v ); 59 | 60 | gl_FragColor = mix( outputColor, texel, alpha ); 61 | 62 | }` 63 | 64 | }; 65 | 66 | export { LuminosityHighPassShader }; 67 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/functions/BSDF/BRDF_GGX.js: -------------------------------------------------------------------------------- 1 | import F_Schlick from './F_Schlick.js'; 2 | import V_GGX_SmithCorrelated from './V_GGX_SmithCorrelated.js'; 3 | import D_GGX from './D_GGX.js'; 4 | import { transformedNormalView } from '../../accessors/NormalNode.js'; 5 | import { positionViewDirection } from '../../accessors/PositionNode.js'; 6 | import { iridescence } from '../../core/PropertyNode.js'; 7 | import { tslFn } from '../../shadernode/ShaderNode.js'; 8 | 9 | // GGX Distribution, Schlick Fresnel, GGX_SmithCorrelated Visibility 10 | const BRDF_GGX = tslFn( ( inputs ) => { 11 | 12 | const { lightDirection, f0, f90, roughness, iridescenceFresnel } = inputs; 13 | 14 | const normalView = inputs.normalView || transformedNormalView; 15 | 16 | const alpha = roughness.pow2(); // UE4's roughness 17 | 18 | const halfDir = lightDirection.add( positionViewDirection ).normalize(); 19 | 20 | const dotNL = normalView.dot( lightDirection ).clamp(); 21 | const dotNV = normalView.dot( positionViewDirection ).clamp(); // @ TODO: Move to core dotNV 22 | const dotNH = normalView.dot( halfDir ).clamp(); 23 | const dotVH = positionViewDirection.dot( halfDir ).clamp(); 24 | 25 | let F = F_Schlick( { f0, f90, dotVH } ); 26 | 27 | if ( iridescenceFresnel ) { 28 | 29 | F = iridescence.mix( F, iridescenceFresnel ); 30 | 31 | } 32 | 33 | const V = V_GGX_SmithCorrelated( { alpha, dotNL, dotNV } ); 34 | const D = D_GGX( { alpha, dotNH } ); 35 | 36 | return F.mul( V ).mul( D ); 37 | 38 | } ); // validated 39 | 40 | export default BRDF_GGX; 41 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/core/IndexNode.js: -------------------------------------------------------------------------------- 1 | import Node, { addNodeClass } from './Node.js'; 2 | import { varying } from './VaryingNode.js'; 3 | import { nodeImmutable } from '../shadernode/ShaderNode.js'; 4 | 5 | class IndexNode extends Node { 6 | 7 | constructor( scope ) { 8 | 9 | super( 'uint' ); 10 | 11 | this.scope = scope; 12 | 13 | this.isInstanceIndexNode = true; 14 | 15 | } 16 | 17 | generate( builder ) { 18 | 19 | const nodeType = this.getNodeType( builder ); 20 | const scope = this.scope; 21 | 22 | let propertyName; 23 | 24 | if ( scope === IndexNode.VERTEX ) { 25 | 26 | propertyName = builder.getVertexIndex(); 27 | 28 | } else if ( scope === IndexNode.INSTANCE ) { 29 | 30 | propertyName = builder.getInstanceIndex(); 31 | 32 | } else { 33 | 34 | throw new Error( 'THREE.IndexNode: Unknown scope: ' + scope ); 35 | 36 | } 37 | 38 | let output; 39 | 40 | if ( builder.shaderStage === 'vertex' || builder.shaderStage === 'compute' ) { 41 | 42 | output = propertyName; 43 | 44 | } else { 45 | 46 | const nodeVarying = varying( this ); 47 | 48 | output = nodeVarying.build( builder, nodeType ); 49 | 50 | } 51 | 52 | return output; 53 | 54 | } 55 | 56 | } 57 | 58 | IndexNode.VERTEX = 'vertex'; 59 | IndexNode.INSTANCE = 'instance'; 60 | 61 | export default IndexNode; 62 | 63 | export const vertexIndex = nodeImmutable( IndexNode, IndexNode.VERTEX ); 64 | export const instanceIndex = nodeImmutable( IndexNode, IndexNode.INSTANCE ); 65 | 66 | addNodeClass( 'IndexNode', IndexNode ); 67 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/utils/JoinNode.js: -------------------------------------------------------------------------------- 1 | import { addNodeClass } from '../core/Node.js'; 2 | import TempNode from '../core/TempNode.js'; 3 | 4 | class JoinNode extends TempNode { 5 | 6 | constructor( nodes = [], nodeType = null ) { 7 | 8 | super( nodeType ); 9 | 10 | this.nodes = nodes; 11 | 12 | } 13 | 14 | getNodeType( builder ) { 15 | 16 | if ( this.nodeType !== null ) { 17 | 18 | return builder.getVectorType( this.nodeType ); 19 | 20 | } 21 | 22 | return builder.getTypeFromLength( this.nodes.reduce( ( count, cur ) => count + builder.getTypeLength( cur.getNodeType( builder ) ), 0 ) ); 23 | 24 | } 25 | 26 | generate( builder, output ) { 27 | 28 | const type = this.getNodeType( builder ); 29 | const nodes = this.nodes; 30 | 31 | const primitiveType = builder.getPrimitiveType( type ); 32 | 33 | const snippetValues = []; 34 | 35 | for ( const input of nodes ) { 36 | 37 | let inputSnippet = input.build( builder ); 38 | 39 | const inputPrimitiveType = builder.getPrimitiveType( input.getNodeType( builder ) ); 40 | 41 | if ( inputPrimitiveType !== primitiveType ) { 42 | 43 | inputSnippet = builder.format( inputSnippet, inputPrimitiveType, primitiveType ); 44 | 45 | } 46 | 47 | snippetValues.push( inputSnippet ); 48 | 49 | } 50 | 51 | const snippet = `${ builder.getType( type ) }( ${ snippetValues.join( ', ' ) } )`; 52 | 53 | return builder.format( snippet, type, output ); 54 | 55 | } 56 | 57 | } 58 | 59 | export default JoinNode; 60 | 61 | addNodeClass( 'JoinNode', JoinNode ); 62 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/curves/NURBSSurface.js: -------------------------------------------------------------------------------- 1 | import { 2 | Vector4 3 | } from 'three'; 4 | import * as NURBSUtils from '../curves/NURBSUtils.js'; 5 | 6 | /** 7 | * NURBS surface object 8 | * 9 | * Implementation is based on (x, y [, z=0 [, w=1]]) control points with w=weight. 10 | **/ 11 | 12 | class NURBSSurface { 13 | 14 | constructor( degree1, degree2, knots1, knots2 /* arrays of reals */, controlPoints /* array^2 of Vector(2|3|4) */ ) { 15 | 16 | this.degree1 = degree1; 17 | this.degree2 = degree2; 18 | this.knots1 = knots1; 19 | this.knots2 = knots2; 20 | this.controlPoints = []; 21 | 22 | const len1 = knots1.length - degree1 - 1; 23 | const len2 = knots2.length - degree2 - 1; 24 | 25 | // ensure Vector4 for control points 26 | for ( let i = 0; i < len1; ++ i ) { 27 | 28 | this.controlPoints[ i ] = []; 29 | 30 | for ( let j = 0; j < len2; ++ j ) { 31 | 32 | const point = controlPoints[ i ][ j ]; 33 | this.controlPoints[ i ][ j ] = new Vector4( point.x, point.y, point.z, point.w ); 34 | 35 | } 36 | 37 | } 38 | 39 | } 40 | 41 | getPoint( t1, t2, target ) { 42 | 43 | const u = this.knots1[ 0 ] + t1 * ( this.knots1[ this.knots1.length - 1 ] - this.knots1[ 0 ] ); // linear mapping t1->u 44 | const v = this.knots2[ 0 ] + t2 * ( this.knots2[ this.knots2.length - 1 ] - this.knots2[ 0 ] ); // linear mapping t2->u 45 | 46 | NURBSUtils.calcSurfacePoint( this.degree1, this.degree2, this.knots1, this.knots2, this.controlPoints, u, v, target ); 47 | 48 | } 49 | 50 | } 51 | 52 | export { NURBSSurface }; 53 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/renderers/common/Info.js: -------------------------------------------------------------------------------- 1 | class Info { 2 | 3 | constructor() { 4 | 5 | this.autoReset = true; 6 | 7 | this.frame = 0; 8 | this.calls = 0; 9 | 10 | this.render = { 11 | calls: 0, 12 | drawCalls: 0, 13 | triangles: 0, 14 | points: 0, 15 | lines: 0 16 | }; 17 | 18 | this.compute = { 19 | calls: 0 20 | }; 21 | 22 | this.memory = { 23 | geometries: 0, 24 | textures: 0 25 | }; 26 | 27 | } 28 | 29 | update( object, count, instanceCount ) { 30 | 31 | this.render.drawCalls ++; 32 | 33 | if ( object.isMesh || object.isSprite ) { 34 | 35 | this.render.triangles += instanceCount * ( count / 3 ); 36 | 37 | } else if ( object.isPoints ) { 38 | 39 | this.render.points += instanceCount * count; 40 | 41 | } else if ( object.isLineSegments ) { 42 | 43 | this.render.lines += instanceCount * ( count / 2 ); 44 | 45 | } else if ( object.isLine ) { 46 | 47 | this.render.lines += instanceCount * ( count - 1 ); 48 | 49 | } else { 50 | 51 | console.error( 'THREE.WebGPUInfo: Unknown object type.' ); 52 | 53 | } 54 | 55 | } 56 | 57 | reset() { 58 | 59 | this.render.drawCalls = 0; 60 | this.render.triangles = 0; 61 | this.render.points = 0; 62 | this.render.lines = 0; 63 | 64 | } 65 | 66 | dispose() { 67 | 68 | this.reset(); 69 | 70 | this.calls = 0; 71 | 72 | this.render.calls = 0; 73 | this.compute.calls = 0; 74 | 75 | this.memory.geometries = 0; 76 | this.memory.textures = 0; 77 | 78 | } 79 | 80 | } 81 | 82 | 83 | export default Info; 84 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/shaders/DotScreenShader.js: -------------------------------------------------------------------------------- 1 | import { 2 | Vector2 3 | } from 'three'; 4 | 5 | /** 6 | * Dot screen shader 7 | * based on glfx.js sepia shader 8 | * https://github.com/evanw/glfx.js 9 | */ 10 | 11 | const DotScreenShader = { 12 | 13 | name: 'DotScreenShader', 14 | 15 | uniforms: { 16 | 17 | 'tDiffuse': { value: null }, 18 | 'tSize': { value: new Vector2( 256, 256 ) }, 19 | 'center': { value: new Vector2( 0.5, 0.5 ) }, 20 | 'angle': { value: 1.57 }, 21 | 'scale': { value: 1.0 } 22 | 23 | }, 24 | 25 | vertexShader: /* glsl */` 26 | 27 | varying vec2 vUv; 28 | 29 | void main() { 30 | 31 | vUv = uv; 32 | gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 33 | 34 | }`, 35 | 36 | fragmentShader: /* glsl */` 37 | 38 | uniform vec2 center; 39 | uniform float angle; 40 | uniform float scale; 41 | uniform vec2 tSize; 42 | 43 | uniform sampler2D tDiffuse; 44 | 45 | varying vec2 vUv; 46 | 47 | float pattern() { 48 | 49 | float s = sin( angle ), c = cos( angle ); 50 | 51 | vec2 tex = vUv * tSize - center; 52 | vec2 point = vec2( c * tex.x - s * tex.y, s * tex.x + c * tex.y ) * scale; 53 | 54 | return ( sin( point.x ) * sin( point.y ) ) * 4.0; 55 | 56 | } 57 | 58 | void main() { 59 | 60 | vec4 color = texture2D( tDiffuse, vUv ); 61 | 62 | float average = ( color.r + color.g + color.b ) / 3.0; 63 | 64 | gl_FragColor = vec4( vec3( average * 10.0 - 5.0 + pattern() ), color.a ); 65 | 66 | }` 67 | 68 | }; 69 | 70 | export { DotScreenShader }; 71 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/postprocessing/FilmPass.js: -------------------------------------------------------------------------------- 1 | import { 2 | ShaderMaterial, 3 | UniformsUtils 4 | } from 'three'; 5 | import { Pass, FullScreenQuad } from './Pass.js'; 6 | import { FilmShader } from '../shaders/FilmShader.js'; 7 | 8 | class FilmPass extends Pass { 9 | 10 | constructor( intensity = 0.5, grayscale = false ) { 11 | 12 | super(); 13 | 14 | const shader = FilmShader; 15 | 16 | this.uniforms = UniformsUtils.clone( shader.uniforms ); 17 | 18 | this.material = new ShaderMaterial( { 19 | 20 | name: shader.name, 21 | uniforms: this.uniforms, 22 | vertexShader: shader.vertexShader, 23 | fragmentShader: shader.fragmentShader 24 | 25 | } ); 26 | 27 | this.uniforms.intensity.value = intensity; // (0 = no effect, 1 = full effect) 28 | this.uniforms.grayscale.value = grayscale; 29 | 30 | this.fsQuad = new FullScreenQuad( this.material ); 31 | 32 | } 33 | 34 | render( renderer, writeBuffer, readBuffer, deltaTime /*, maskActive */ ) { 35 | 36 | this.uniforms[ 'tDiffuse' ].value = readBuffer.texture; 37 | this.uniforms[ 'time' ].value += deltaTime; 38 | 39 | if ( this.renderToScreen ) { 40 | 41 | renderer.setRenderTarget( null ); 42 | this.fsQuad.render( renderer ); 43 | 44 | } else { 45 | 46 | renderer.setRenderTarget( writeBuffer ); 47 | if ( this.clear ) renderer.clear(); 48 | this.fsQuad.render( renderer ); 49 | 50 | } 51 | 52 | } 53 | 54 | dispose() { 55 | 56 | this.material.dispose(); 57 | 58 | this.fsQuad.dispose(); 59 | 60 | } 61 | 62 | } 63 | 64 | export { FilmPass }; 65 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/core/NodeKeywords.js: -------------------------------------------------------------------------------- 1 | class NodeKeywords { 2 | 3 | constructor() { 4 | 5 | this.keywords = []; 6 | this.nodes = []; 7 | this.keywordsCallback = {}; 8 | 9 | } 10 | 11 | getNode( name ) { 12 | 13 | let node = this.nodes[ name ]; 14 | 15 | if ( node === undefined && this.keywordsCallback[ name ] !== undefined ) { 16 | 17 | node = this.keywordsCallback[ name ]( name ); 18 | 19 | this.nodes[ name ] = node; 20 | 21 | } 22 | 23 | return node; 24 | 25 | } 26 | 27 | addKeyword( name, callback ) { 28 | 29 | this.keywords.push( name ); 30 | this.keywordsCallback[ name ] = callback; 31 | 32 | return this; 33 | 34 | } 35 | 36 | parse( code ) { 37 | 38 | const keywordNames = this.keywords; 39 | 40 | const regExp = new RegExp( `\\b${keywordNames.join( '\\b|\\b' )}\\b`, 'g' ); 41 | 42 | const codeKeywords = code.match( regExp ); 43 | 44 | const keywordNodes = []; 45 | 46 | if ( codeKeywords !== null ) { 47 | 48 | for ( const keyword of codeKeywords ) { 49 | 50 | const node = this.getNode( keyword ); 51 | 52 | if ( node !== undefined && keywordNodes.indexOf( node ) === - 1 ) { 53 | 54 | keywordNodes.push( node ); 55 | 56 | } 57 | 58 | } 59 | 60 | } 61 | 62 | return keywordNodes; 63 | 64 | } 65 | 66 | include( builder, code ) { 67 | 68 | const keywordNodes = this.parse( code ); 69 | 70 | for ( const keywordNode of keywordNodes ) { 71 | 72 | keywordNode.build( builder ); 73 | 74 | } 75 | 76 | } 77 | 78 | } 79 | 80 | export default NodeKeywords; 81 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/core/OutputStructNode.js: -------------------------------------------------------------------------------- 1 | import Node, { addNodeClass } from './Node.js'; 2 | import StructTypeNode from './StructTypeNode.js'; 3 | import { nodeProxy } from '../shadernode/ShaderNode.js'; 4 | 5 | class OutputStructNode extends Node { 6 | 7 | constructor( ...members ) { 8 | 9 | super(); 10 | 11 | this.isOutputStructNode = true; 12 | this.members = members; 13 | 14 | } 15 | 16 | setup( builder ) { 17 | 18 | super.setup( builder ); 19 | 20 | const members = this.members; 21 | const types = []; 22 | 23 | for ( let i = 0; i < members.length; i ++ ) { 24 | 25 | types.push( members[ i ].getNodeType( builder ) ); 26 | 27 | } 28 | 29 | this.nodeType = builder.getStructTypeFromNode( new StructTypeNode( types ) ).name; 30 | 31 | } 32 | 33 | generate( builder, output ) { 34 | 35 | const nodeVar = builder.getVarFromNode( this ); 36 | nodeVar.isOutputStructVar = true; 37 | 38 | const propertyName = builder.getPropertyName( nodeVar ); 39 | 40 | const members = this.members; 41 | 42 | const structPrefix = propertyName !== '' ? propertyName + '.' : ''; 43 | 44 | for ( let i = 0; i < members.length; i ++ ) { 45 | 46 | const snippet = members[ i ].build( builder, output ); 47 | 48 | builder.addLineFlowCode( `${ structPrefix }m${ i } = ${ snippet }` ); 49 | 50 | } 51 | 52 | return propertyName; 53 | 54 | } 55 | 56 | } 57 | 58 | export default OutputStructNode; 59 | 60 | export const outputStruct = nodeProxy( OutputStructNode ); 61 | 62 | addNodeClass( 'OutputStructNode', OutputStructNode ); 63 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/core/TempNode.js: -------------------------------------------------------------------------------- 1 | import Node, { addNodeClass } from './Node.js'; 2 | 3 | class TempNode extends Node { 4 | 5 | constructor( type ) { 6 | 7 | super( type ); 8 | 9 | this.isTempNode = true; 10 | 11 | } 12 | 13 | hasDependencies( builder ) { 14 | 15 | return builder.getDataFromNode( this ).dependenciesCount > 1; 16 | 17 | } 18 | 19 | build( builder, output ) { 20 | 21 | const buildStage = builder.getBuildStage(); 22 | 23 | if ( buildStage === 'generate' ) { 24 | 25 | const type = builder.getVectorType( this.getNodeType( builder, output ) ); 26 | const nodeData = builder.getDataFromNode( this ); 27 | 28 | if ( builder.context.tempRead !== false && nodeData.propertyName !== undefined ) { 29 | 30 | return builder.format( nodeData.propertyName, type, output ); 31 | 32 | } else if ( builder.context.tempWrite !== false && type !== 'void' && output !== 'void' && this.hasDependencies( builder ) ) { 33 | 34 | const snippet = super.build( builder, type ); 35 | 36 | const nodeVar = builder.getVarFromNode( this, null, type ); 37 | const propertyName = builder.getPropertyName( nodeVar ); 38 | 39 | builder.addLineFlowCode( `${propertyName} = ${snippet}` ); 40 | 41 | nodeData.snippet = snippet; 42 | nodeData.propertyName = propertyName; 43 | 44 | return builder.format( nodeData.propertyName, type, output ); 45 | 46 | } 47 | 48 | } 49 | 50 | return super.build( builder, output ); 51 | 52 | } 53 | 54 | } 55 | 56 | export default TempNode; 57 | 58 | addNodeClass( 'TempNode', TempNode ); 59 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/renderers/common/ChainMap.js: -------------------------------------------------------------------------------- 1 | export default class ChainMap { 2 | 3 | constructor() { 4 | 5 | this.weakMap = new WeakMap(); 6 | 7 | } 8 | 9 | get( keys ) { 10 | 11 | if ( Array.isArray( keys ) ) { 12 | 13 | let map = this.weakMap; 14 | 15 | for ( let i = 0; i < keys.length; i ++ ) { 16 | 17 | map = map.get( keys[ i ] ); 18 | 19 | if ( map === undefined ) return undefined; 20 | 21 | } 22 | 23 | return map.get( keys[ keys.length - 1 ] ); 24 | 25 | } else { 26 | 27 | return super.get( keys ); 28 | 29 | } 30 | 31 | } 32 | 33 | set( keys, value ) { 34 | 35 | if ( Array.isArray( keys ) ) { 36 | 37 | let map = this.weakMap; 38 | 39 | for ( let i = 0; i < keys.length; i ++ ) { 40 | 41 | const key = keys[ i ]; 42 | 43 | if ( map.has( key ) === false ) map.set( key, new WeakMap() ); 44 | 45 | map = map.get( key ); 46 | 47 | } 48 | 49 | return map.set( keys[ keys.length - 1 ], value ); 50 | 51 | } else { 52 | 53 | return super.set( keys, value ); 54 | 55 | } 56 | 57 | } 58 | 59 | delete( keys ) { 60 | 61 | if ( Array.isArray( keys ) ) { 62 | 63 | let map = this.weakMap; 64 | 65 | for ( let i = 0; i < keys.length; i ++ ) { 66 | 67 | map = map.get( keys[ i ] ); 68 | 69 | if ( map === undefined ) return false; 70 | 71 | } 72 | 73 | return map.delete( keys[ keys.length - 1 ] ); 74 | 75 | } else { 76 | 77 | return super.delete( keys ); 78 | 79 | } 80 | 81 | } 82 | 83 | dispose() { 84 | 85 | this.weakMap.clear(); 86 | 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /src/planner/solver/util.py: -------------------------------------------------------------------------------- 1 | from constants import l 2 | import casadi as ca 3 | import math 4 | 5 | def corners(theta): 6 | c = ca.cos(theta) 7 | s = ca.sin(theta) 8 | 9 | return [rotate(-l*math.sqrt(2), l*math.sqrt(2), c, s), 10 | rotate(l*math.sqrt(2), l*math.sqrt(2), c, s), 11 | rotate(-l*math.sqrt(2), -l*math.sqrt(2), c, s), 12 | rotate(l*math.sqrt(2), -l*math.sqrt(2), c, s)] 13 | 14 | def rotate(x, y, c, s): 15 | return [x * c - y * s, y * c + x * s] 16 | 17 | def interpolate(t0, t1, t2, a, b): 18 | w = (t1 - t0) / (t2 - t0) 19 | return a * (1 -w) + b * (w) 20 | 21 | def split_even_dt(dts, way_i, x, y, theta): 22 | timestamp = [0] 23 | for i in range(1, len(way_i)): 24 | from_i = way_i[i - 1] 25 | to_i = way_i[i] 26 | dt_seg = dts[i-1] 27 | for j in range(from_i, to_i): 28 | timestamp.append(timestamp[-1] + dt_seg) 29 | 30 | split_dt = 0.02 31 | 32 | split_x = [] 33 | split_y = [] 34 | split_theta = [] 35 | 36 | time = 0 37 | i = 0 38 | 39 | while (i < way_i[-1]): 40 | if (time >= timestamp[i] and time <= timestamp[i+1]): 41 | split_x.append(interpolate(timestamp[i], time, timestamp[i+1], x[i], x[i+1])) 42 | split_y.append(interpolate(timestamp[i], time, timestamp[i+1], y[i], y[i+1])) 43 | split_theta.append(interpolate(timestamp[i], time, timestamp[i+1], theta[i], theta[i+1])) 44 | time += split_dt 45 | else: 46 | i+=1 47 | 48 | return [split_x, split_y, split_theta] 49 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/geometries/TextGeometry.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Text = 3D Text 3 | * 4 | * parameters = { 5 | * font: , // font 6 | * 7 | * size: , // size of the text 8 | * height: , // thickness to extrude text 9 | * curveSegments: , // number of points on the curves 10 | * 11 | * bevelEnabled: , // turn on bevel 12 | * bevelThickness: , // how deep into text bevel goes 13 | * bevelSize: , // how far from text outline (including bevelOffset) is bevel 14 | * bevelOffset: // how far from text outline does bevel start 15 | * } 16 | */ 17 | 18 | import { 19 | ExtrudeGeometry 20 | } from 'three'; 21 | 22 | class TextGeometry extends ExtrudeGeometry { 23 | 24 | constructor( text, parameters = {} ) { 25 | 26 | const font = parameters.font; 27 | 28 | if ( font === undefined ) { 29 | 30 | super(); // generate default extrude geometry 31 | 32 | } else { 33 | 34 | const shapes = font.generateShapes( text, parameters.size ); 35 | 36 | // translate parameters to ExtrudeGeometry API 37 | 38 | parameters.depth = parameters.height !== undefined ? parameters.height : 50; 39 | 40 | // defaults 41 | 42 | if ( parameters.bevelThickness === undefined ) parameters.bevelThickness = 10; 43 | if ( parameters.bevelSize === undefined ) parameters.bevelSize = 8; 44 | if ( parameters.bevelEnabled === undefined ) parameters.bevelEnabled = false; 45 | 46 | super( shapes, parameters ); 47 | 48 | } 49 | 50 | this.type = 'TextGeometry'; 51 | 52 | } 53 | 54 | } 55 | 56 | 57 | export { TextGeometry }; 58 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/utils/SetNode.js: -------------------------------------------------------------------------------- 1 | import { addNodeClass } from '../core/Node.js'; 2 | import TempNode from '../core/TempNode.js'; 3 | import { vectorComponents } from '../core/constants.js'; 4 | 5 | class SetNode extends TempNode { 6 | 7 | constructor( sourceNode, components, targetNode ) { 8 | 9 | super(); 10 | 11 | this.sourceNode = sourceNode; 12 | this.components = components; 13 | this.targetNode = targetNode; 14 | 15 | } 16 | 17 | getNodeType( builder ) { 18 | 19 | return this.sourceNode.getNodeType( builder ); 20 | 21 | } 22 | 23 | generate( builder ) { 24 | 25 | const { sourceNode, components, targetNode } = this; 26 | 27 | const sourceType = this.getNodeType( builder ); 28 | const targetType = builder.getTypeFromLength( components.length ); 29 | 30 | const targetSnippet = targetNode.build( builder, targetType ); 31 | const sourceSnippet = sourceNode.build( builder, sourceType ); 32 | 33 | const length = builder.getTypeLength( sourceType ); 34 | const snippetValues = []; 35 | 36 | for ( let i = 0; i < length; i ++ ) { 37 | 38 | const component = vectorComponents[ i ]; 39 | 40 | if ( component === components[ 0 ] ) { 41 | 42 | snippetValues.push( targetSnippet ); 43 | 44 | i += components.length - 1; 45 | 46 | } else { 47 | 48 | snippetValues.push( sourceSnippet + '.' + component ); 49 | 50 | } 51 | 52 | } 53 | 54 | return `${ builder.getType( sourceType ) }( ${ snippetValues.join( ', ' ) } )`; 55 | 56 | } 57 | 58 | } 59 | 60 | export default SetNode; 61 | 62 | addNodeClass( 'SetNode', SetNode ); 63 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/environments/DebugEnvironment.js: -------------------------------------------------------------------------------- 1 | import { 2 | BackSide, 3 | BoxGeometry, 4 | Mesh, 5 | MeshLambertMaterial, 6 | MeshStandardMaterial, 7 | PointLight, 8 | Scene, 9 | } from 'three'; 10 | 11 | class DebugEnvironment extends Scene { 12 | 13 | constructor() { 14 | 15 | super(); 16 | 17 | const geometry = new BoxGeometry(); 18 | geometry.deleteAttribute( 'uv' ); 19 | const roomMaterial = new MeshStandardMaterial( { metalness: 0, side: BackSide } ); 20 | const room = new Mesh( geometry, roomMaterial ); 21 | room.scale.setScalar( 10 ); 22 | this.add( room ); 23 | 24 | const mainLight = new PointLight( 0xffffff, 50, 0, 2 ); 25 | this.add( mainLight ); 26 | 27 | const material1 = new MeshLambertMaterial( { color: 0xff0000, emissive: 0xffffff, emissiveIntensity: 10 } ); 28 | 29 | const light1 = new Mesh( geometry, material1 ); 30 | light1.position.set( - 5, 2, 0 ); 31 | light1.scale.set( 0.1, 1, 1 ); 32 | this.add( light1 ); 33 | 34 | const material2 = new MeshLambertMaterial( { color: 0x00ff00, emissive: 0xffffff, emissiveIntensity: 10 } ); 35 | 36 | const light2 = new Mesh( geometry, material2 ); 37 | light2.position.set( 0, 5, 0 ); 38 | light2.scale.set( 1, 0.1, 1 ); 39 | this.add( light2 ); 40 | 41 | const material3 = new MeshLambertMaterial( { color: 0x0000ff, emissive: 0xffffff, emissiveIntensity: 10 } ); 42 | 43 | const light3 = new Mesh( geometry, material3 ); 44 | light3.position.set( 2, 1, 5 ); 45 | light3.scale.set( 1.5, 2, 0.1 ); 46 | this.add( light3 ); 47 | 48 | } 49 | 50 | } 51 | 52 | export { DebugEnvironment }; 53 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/nodes/core/AssignNode.js: -------------------------------------------------------------------------------- 1 | import { addNodeClass } from '../core/Node.js'; 2 | import TempNode from '../core/TempNode.js'; 3 | import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js'; 4 | 5 | class AssignNode extends TempNode { 6 | 7 | constructor( targetNode, sourceNode ) { 8 | 9 | super(); 10 | 11 | this.targetNode = targetNode; 12 | this.sourceNode = sourceNode; 13 | 14 | } 15 | 16 | hasDependencies() { 17 | 18 | return false; 19 | 20 | } 21 | 22 | getNodeType( builder, output ) { 23 | 24 | return output !== 'void' ? this.targetNode.getNodeType( builder ) : 'void'; 25 | 26 | } 27 | 28 | generate( builder, output ) { 29 | 30 | const targetNode = this.targetNode; 31 | const sourceNode = this.sourceNode; 32 | 33 | const targetType = targetNode.getNodeType( builder ); 34 | 35 | const target = targetNode.build( builder ); 36 | const source = sourceNode.build( builder, targetType ); 37 | 38 | const snippet = `${ target } = ${ source }`; 39 | 40 | if ( output === 'void' ) { 41 | 42 | builder.addLineFlowCode( snippet ); 43 | 44 | return; 45 | 46 | } else { 47 | 48 | const sourceType = sourceNode.getNodeType( builder ); 49 | 50 | if ( sourceType === 'void' ) { 51 | 52 | builder.addLineFlowCode( snippet ); 53 | 54 | return target; 55 | 56 | } 57 | 58 | return builder.format( snippet, targetType, output ); 59 | 60 | } 61 | 62 | } 63 | 64 | } 65 | 66 | export default AssignNode; 67 | 68 | export const assign = nodeProxy( AssignNode ); 69 | 70 | addNodeClass( 'AssignNode', AssignNode ); 71 | 72 | addNodeElement( 'assign', assign ); 73 | -------------------------------------------------------------------------------- /src/assets/modules/three-addons/libs/draco/README.md: -------------------------------------------------------------------------------- 1 | # Draco 3D Data Compression 2 | 3 | Draco is an open-source library for compressing and decompressing 3D geometric meshes and point clouds. It is intended to improve the storage and transmission of 3D graphics. 4 | 5 | [Website](https://google.github.io/draco/) | [GitHub](https://github.com/google/draco) 6 | 7 | ## Contents 8 | 9 | This folder contains three utilities: 10 | 11 | * `draco_decoder.js` — Emscripten-compiled decoder, compatible with any modern browser. 12 | * `draco_decoder.wasm` — WebAssembly decoder, compatible with newer browsers and devices. 13 | * `draco_wasm_wrapper.js` — JavaScript wrapper for the WASM decoder. 14 | 15 | Each file is provided in two variations: 16 | 17 | * **Default:** Latest stable builds, tracking the project's [master branch](https://github.com/google/draco). 18 | * **glTF:** Builds targeted by the [glTF mesh compression extension](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression), tracking the [corresponding Draco branch](https://github.com/google/draco/tree/gltf_2.0_draco_extension). 19 | 20 | Either variation may be used with `THREE.DRACOLoader`: 21 | 22 | ```js 23 | var dracoLoader = new THREE.DRACOLoader(); 24 | dracoLoader.setDecoderPath('path/to/decoders/'); 25 | dracoLoader.setDecoderConfig({type: 'js'}); // (Optional) Override detection of WASM support. 26 | ``` 27 | 28 | Further [documentation on GitHub](https://github.com/google/draco/tree/master/javascript/example#static-loading-javascript-decoder). 29 | 30 | ## License 31 | 32 | [Apache License 2.0](https://github.com/google/draco/blob/master/LICENSE) 33 | --------------------------------------------------------------------------------