@woosh/meep-engine 2.56.1 → 2.58.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/editor/Editor.js +4 -4
- package/editor/ecs/component/editors/ColorEditor.js +1 -1
- package/editor/ecs/component/editors/ImagePathEditor.js +2 -2
- package/editor/ecs/component/editors/{LargeStrongEditor.js → LargeStringEditor.js} +1 -1
- package/editor/process/symbolic/buildThreeJSHelperEntity.js +3 -3
- package/editor/process/symbolic/makeGridPositionSymbolDisplay.js +3 -3
- package/editor/process/symbolic/makePositionedIconDisplaySymbol.js +3 -3
- package/editor/tools/GridPaintTool.js +3 -3
- package/editor/tools/TopDownCameraControlTool.js +1 -1
- package/editor/tools/TransformTool.js +1 -1
- package/editor/tools/engine/Tool.js +9 -23
- package/editor/tools/engine/ToolEngine.js +5 -7
- package/editor/tools/paint/TerrainHeightPaintTool.js +2 -2
- package/editor/tools/paint/TerrainPaintTool.js +2 -2
- package/editor/tools/paint/TerrainTexturePaintTool.js +2 -2
- package/editor/tools/v2/prototypeTransformControls.js +3 -3
- package/editor/view/ecs/ComponentControlView.js +2 -1
- package/package.json +1 -1
- package/samples/generation/main.js +2 -2
- package/samples/terrain/from_image.js +2 -2
- package/samples/terrain/from_image_2.js +4 -4
- package/src/core/binary/byteArrayToString.js +28 -0
- package/src/core/binary/downloadAsFile.js +28 -0
- package/src/core/binary/downloadUrlAsFile.js +14 -0
- package/src/core/binary/jsonToStringToByteArray.js +27 -0
- package/src/core/binary/stringToByteArray.js +24 -0
- package/src/core/bvh2/BinaryNode.spec.js +2 -1
- package/src/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.js +1 -1
- package/src/core/bvh2/traversal/ThreeClippingPlaneComputingBVHVisitor.js +1 -1
- package/src/core/bvh2/traversal/__process_point_if_within_planes.js +1 -1
- package/src/core/cache/LoadingCache.js +3 -2
- package/src/core/collection/array/arraySetSortingDiff.spec.js +12 -12
- package/src/core/collection/array/weightedRandomFromArray.js +2 -2
- package/src/core/color/Color.js +6 -6
- package/src/core/color/Color.spec.js +27 -1
- package/src/core/color/YCbCr/YCbCr.spec.js +16 -0
- package/src/core/color/{YCbCr_to_rgb_uint24.js → YCbCr/YCbCr_to_rgb_uint24.js} +6 -6
- package/src/core/color/YCbCr/rgb_to_YCbCr_uint24.js +16 -0
- package/src/core/color/{hex2rgb.js → hex/hex2rgb.js} +1 -1
- package/src/core/color/{rgb2hex.js → hex/rgb2hex.js} +1 -1
- package/src/core/color/{hsv2rgb.js → hsv/hsv2rgb.js} +3 -3
- package/src/core/color/hsv/rgb2hsv.js +49 -0
- package/src/core/color/{kelvin_to_rgb.js → kelvin/kelvin_to_rgb.js} +1 -1
- package/src/core/color/{kelvin_to_rgb.spec.js → kelvin/kelvin_to_rgb.spec.js} +2 -2
- package/src/core/color/{prototype_kelvin_to_rgb.js → kelvin/prototype_kelvin_to_rgb.js} +5 -5
- package/src/core/color/{rgb_to_kelvin.spec.js → kelvin/rgb_to_kelvin.spec.js} +1 -1
- package/src/core/color/{parseColor.js → parse_color.js} +5 -5
- package/src/core/color/parse_color.spec.js +18 -0
- package/src/core/color/rgb2uint24.js +3 -3
- package/src/core/color/sRGB/sRGB.spec.js +16 -0
- package/src/core/color/xyz/XYZ.spec.js +16 -0
- package/src/core/color/xyz/rgb_to_xyz.js +15 -0
- package/src/core/color/xyz/xyz_to_rgb.js +14 -0
- package/src/core/events/signal/Signal.js +5 -0
- package/src/core/events/signal/{signalAggregateByTimeWindow.js → signal_aggregate_by_time_window.js} +1 -1
- package/src/core/events/signal/{SignalUtils.js → signal_filter.js} +1 -2
- package/src/core/fsm/simple/SimpleStateMachine.spec.js +34 -2
- package/src/core/geom/2d/spline_bezier2_2d.js +26 -0
- package/src/core/geom/2d/spline_bezier2_2d.spec.js +16 -0
- package/src/core/geom/3d/SurfacePoint3.js +1 -1
- package/src/core/geom/3d/aabb/aabb3_compute_plane_side.js +1 -1
- package/src/core/geom/3d/aabb/aabb3_detailed_volume_intersection.js +1 -1
- package/src/core/geom/3d/aabb/aabb3_transformed_compute_plane_side.js +1 -1
- package/src/core/geom/3d/compute_circle_bounding_box.js +1 -1
- package/src/core/geom/3d/cone/computeConeBoundingBox.js +1 -1
- package/src/core/geom/3d/frustum/frustum3_computeNearestPointToPoint.js +1 -1
- package/src/core/geom/3d/line/line3_computeSegmentPointDistance_sqr.js +1 -1
- package/src/core/geom/3d/line/line3_compute_nearest_point_to_point.js +1 -1
- package/src/core/geom/3d/matrix/m4_multiply.js +2 -2
- package/src/core/geom/3d/matrix/m4_multiply.spec.js +11 -0
- package/src/core/geom/3d/matrix/m4_multiply_alphatensor.spec.js +11 -0
- package/src/core/geom/3d/morton/split_by_2.js +1 -1
- package/src/core/geom/3d/normal/hemioct/unit_hemioct.spec.js +1 -1
- package/src/core/geom/3d/normal/spherical/sphere_map_transform.js +1 -1
- package/src/core/geom/3d/plane/is_point_within_planes.js +1 -1
- package/src/core/geom/3d/plane/lerp_planes_to_array.js +1 -1
- package/src/core/geom/3d/plane/plane3_compute_convex_3_plane_intersection.js +1 -1
- package/src/core/geom/3d/plane/plane3_compute_line_segment_intersection.js +1 -1
- package/src/core/geom/3d/plane/plane3_compute_ray_intersection.js +1 -1
- package/src/core/geom/3d/plane/plane3_lerp.js +2 -2
- package/src/core/geom/3d/plane/plane3_projectPoint.js +1 -1
- package/src/core/geom/3d/plane/plane3_slerp.js +3 -3
- package/src/core/geom/3d/ray/ray_computeNearestPointToPoint.js +1 -1
- package/src/core/geom/3d/ray/ray_distance_to_point.js +1 -1
- package/src/core/geom/3d/shape/UnionShape3D.js +3 -3
- package/src/core/geom/3d/shape/UnitCubeShape3D.js +1 -1
- package/src/core/geom/3d/shape/UnitSphereShape3D.js +1 -1
- package/src/core/geom/3d/shape/util/shape_to_visual_entity.js +10 -10
- package/src/core/geom/3d/sphere/sphere_intersects_ray.js +1 -1
- package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +6 -0
- package/src/core/geom/3d/tetrahedra/compute_bounding_simplex_3d.js +1 -1
- package/src/core/geom/3d/tetrahedra/compute_bounding_simplex_3d.spec.js +1 -1
- package/src/core/geom/3d/tetrahedra/compute_circumsphere.js +1 -1
- package/src/core/geom/3d/tetrahedra/delaunay/compute_delaunay_tetrahedral_mesh.js +1 -0
- package/src/core/geom/3d/tetrahedra/delaunay/compute_delaunay_tetrahedral_mesh.spec.js +10 -2
- package/src/core/geom/3d/tetrahedra/prototypeTetrahedraBuilder.js +2 -2
- package/src/core/geom/3d/topology/bounds/computeTriangleClusterNormalBoundingCone.js +1 -1
- package/src/core/geom/3d/topology/samples/sampleFloodFill.js +4 -4
- package/src/core/geom/3d/topology/simplify/compute_face_normal_change_dot_product.js +1 -1
- package/src/core/geom/3d/topology/simplify/quadratic/Quadratic3.js +1 -1
- package/src/core/geom/3d/topology/simplify/tm_edge_collapse_is_degenerate_flip.js +2 -2
- package/src/core/geom/3d/topology/struct/TopoVertex.js +1 -1
- package/src/core/geom/3d/topology/util/compute_face_connection_weight.js +2 -2
- package/src/core/geom/3d/triangle/computeTrianglePlaneSide.js +1 -1
- package/src/core/geom/3d/triangle/computeTriangleRayIntersection.js +1 -1
- package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricEdge.js +1 -1
- package/src/core/geom/3d/v3_compute_triangle_normal.js +1 -1
- package/src/core/geom/Quaternion.js +1 -1
- package/src/core/geom/Vector3.js +7 -7
- package/src/core/geom/Vector3.spec.js +68 -1
- package/src/core/geom/mat2/m2_add.js +17 -0
- package/src/core/geom/mat2/m2_determinant.js +8 -0
- package/src/core/geom/mat2/m2_multiply.js +17 -0
- package/src/core/geom/mat2/m2_multiply_scalar.js +18 -0
- package/src/core/geom/mat2/m2_multiply_transposed.js +18 -0
- package/src/core/geom/mat2/m2_sub_transposed.js +17 -0
- package/src/{view → core/geom/mat3}/m3_cm_compose_transform.js +0 -29
- package/src/core/geom/mat3/m3_cm_extract_rotation.js +8 -0
- package/src/core/geom/mat3/m3_cm_from_translation.js +19 -0
- package/src/{view/multiplyMatrices3.js → core/geom/mat3/m3_multiply.js} +2 -2
- package/src/{view → core/geom/mat3}/m3_rm_compose_transform.js +0 -9
- package/src/core/geom/mat3/m3_rm_extract_scale.js +7 -0
- package/src/core/geom/{3d/vector/allocate_v3.js → vec3/v3_allocate.js} +1 -1
- package/src/core/geom/{v3_angle_between.js → vec3/v3_angle_between.js} +1 -1
- package/src/core/geom/vec3/v3_dot_array_array.js +20 -0
- package/src/core/geom/{v3_lerp.js → vec3/v3_lerp.js} +1 -1
- package/src/core/graph/SquareMatrix.js +26 -3
- package/src/core/graph/SquareMatrix.spec.js +52 -2
- package/src/core/math/clamp01.js +1 -0
- package/src/core/math/fract.js +3 -1
- package/src/core/math/inverseLerp.js +7 -5
- package/src/core/math/lerp.js +5 -5
- package/src/core/math/physics/spring/computeHookeForce.js +9 -0
- package/src/core/math/remap.js +19 -0
- package/src/core/math/remap.spec.js +15 -0
- package/src/core/math/smoothStep.spec.js +16 -0
- package/src/core/math/spline/spline_bezier2.js +13 -0
- package/src/core/math/spline/spline_bezier2.spec.js +13 -0
- package/src/core/model/object/compareValues.js +2 -2
- package/src/core/model/object/read_property.js +10 -2
- package/src/core/model/object/write_property.js +3 -23
- package/src/core/model/object/write_property.spec.js +26 -0
- package/src/core/primitives/numbers/number_pretty_print.spec.js +19 -0
- package/src/core/process/action/AsynchronousDelayAction.js +2 -2
- package/src/core/process/executor/profile/ConcurrentExecutorProfiler.js +1 -1
- package/src/engine/EngineHarness.js +7 -7
- package/src/engine/EntityCreator.js +5 -5
- package/src/engine/__module.js +1 -1
- package/src/engine/achievements/AchievementManager.js +2 -2
- package/src/engine/animation/AnimationUtils.js +4 -4
- package/src/engine/animation/behavior/animateProperty.js +2 -2
- package/src/engine/animation/curve/draw/build_plot_entity_from_array.js +3 -3
- package/src/engine/animation/playAnimationTrack.js +3 -3
- package/src/engine/animation/playTrackRealTime.js +3 -3
- package/src/engine/animation/removeEntityWithMeshParticlesEffect.js +2 -2
- package/src/engine/control/ControlContext.js +7 -7
- package/src/engine/ecs/{EntityBuilder.d.ts → Entity.d.ts} +5 -5
- package/src/engine/ecs/{EntityBuilder.js → Entity.js} +29 -29
- package/src/engine/ecs/{EntityBuilder.spec.js → Entity.spec.js} +17 -17
- package/src/engine/ecs/EntityBlueprint.d.ts +2 -2
- package/src/engine/ecs/EntityBlueprint.js +3 -3
- package/src/engine/ecs/EntityBlueprint.spec.js +2 -2
- package/src/engine/ecs/{EntityBuilderFlags.js → EntityFlags.js} +1 -1
- package/src/engine/ecs/EntityObserver.spec.js +8 -8
- package/src/engine/ecs/dynamic_actions/DynamicActorSystem.js +5 -5
- package/src/engine/ecs/foliage/ecs/InstancedMeshUtils.js +3 -3
- package/src/engine/ecs/gui/menu/radial/RadialContextMenu.d.ts +2 -2
- package/src/engine/ecs/gui/menu/radial/RadialContextMenu.js +5 -5
- package/src/engine/ecs/ik/OneBoneSurfaceAlignmentSolver.js +2 -2
- package/src/engine/ecs/ik/TwoBoneInverseKinematicsSolver.js +2 -2
- package/src/engine/ecs/parent/EntityNode.d.ts +3 -3
- package/src/engine/ecs/parent/EntityNode.js +5 -5
- package/src/engine/ecs/parent/testHuDPerf.js +2 -2
- package/src/engine/ecs/speaker/VoiceSystem.js +5 -5
- package/src/engine/ecs/systems/SteeringSystem.js +1 -1
- package/src/engine/ecs/terrain/ecs/splat/SplatMapOptimizerDebugger.js +1 -1
- package/src/engine/ecs/tooltip/testTooltipComponentSystem.js +3 -3
- package/src/engine/graphics/camera/makeOrbitalCameraController.js +3 -3
- package/src/engine/graphics/camera/testClippingPlaneComputation.js +3 -3
- package/src/engine/graphics/debug/createDebugLabel.js +3 -3
- package/src/engine/graphics/ecs/camera/Camera.js +1 -1
- package/src/engine/graphics/ecs/camera/CameraClippingPlaneComputer.js +1 -1
- package/src/engine/graphics/ecs/camera/filter/setup_filtered_camera_controller.js +3 -3
- package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +3 -11
- package/src/engine/graphics/ecs/decal/v2/prototypeDecalEditor.js +3 -3
- package/src/engine/graphics/ecs/decal/v2/prototypeDecalSystem.js +14 -14
- package/src/engine/graphics/ecs/highlight/Highlight.js +20 -102
- package/src/engine/graphics/ecs/mesh/Mesh.js +12 -18
- package/src/engine/graphics/ecs/mesh/MeshSystem.js +41 -26
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +1 -1
- package/src/engine/graphics/ecs/mesh-v2/aggregate/prototypeSGMesh.js +3 -3
- package/src/engine/graphics/ecs/mesh-v2/sample/prototypeShadedGeometry.js +5 -5
- package/src/engine/graphics/ecs/mesh-v2/sample/prototype_sg_raycast.js +6 -6
- package/src/engine/graphics/ecs/path/ribbon/RibbonPathBuilder.js +3 -3
- package/src/engine/graphics/ecs/path/testPathDisplaySystem.js +3 -3
- package/src/engine/graphics/ecs/path/tube/build/TubePathBuilder.js +4 -4
- package/src/engine/graphics/ecs/path/tube/build/makeTubeGeometry.js +1 -1
- package/src/engine/graphics/ecs/path/tube/build/make_cap.js +3 -3
- package/src/engine/graphics/ecs/path/tube/build/make_ring_vertices.js +1 -1
- package/src/engine/graphics/ecs/path/tube/prototypeAnimatedPathMask.js +3 -3
- package/src/engine/graphics/ecs/sprite/SpriteSystemPE.js +2 -2
- package/src/engine/graphics/ecs/sprite/prototypeSpriteSystem.js +2 -2
- package/src/engine/graphics/geometry/MikkT/InitTriInfo.js +5 -6
- package/src/engine/graphics/geometry/MikkT/MikkTSpace.js +3 -3
- package/src/engine/graphics/geometry/MikkT/NormalizeSafe.js +1 -2
- package/src/engine/graphics/geometry/MikkT/STSpace.js +3 -3
- package/src/engine/graphics/geometry/MikkT/v3_scale_dot_sub_normalize.js +2 -2
- package/src/engine/graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js +1 -1
- package/src/engine/graphics/geometry/clipping/ClippedGeometry.js +1 -1
- package/src/engine/graphics/geometry/optimization/merge/prototypeGeometryMerge.js +4 -4
- package/src/engine/graphics/impostors/octahedral/prototypeBaker.js +7 -7
- package/src/engine/graphics/particles/node-based/editor/ParticleSpecificationEditorView.js +1 -1
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +102 -95
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleLayer.spec.js +25 -0
- package/src/engine/graphics/particles/particular/engine/emitter/ParticlePool.js +0 -35
- package/src/engine/graphics/particles/particular/engine/emitter/ParticlePool.spec.js +39 -2
- package/src/engine/graphics/particles/particular/engine/renderers/billboard/prototypeBillboardRenderer.js +2 -2
- package/src/engine/graphics/particles/particular/engine/shader/ShaderManager.js +22 -6
- package/src/engine/graphics/particles/particular/engine/utils/volume/ParticleVolume.d.ts +2 -2
- package/src/engine/graphics/particles/particular/engine/utils/volume/ParticleVolume.js +3 -3
- package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +10 -10
- package/src/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +2 -2
- package/src/engine/graphics/render/buffer/simple-fx/taa/prototypeTAA.js +2 -2
- package/src/engine/graphics/render/forward_plus/LightManager.js +1 -1
- package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +13 -13
- package/src/engine/graphics/render/forward_plus/prototype/prototypeLightManager.js +3 -3
- package/src/engine/graphics/render/forward_plus/query/detailed_sphere_frustum_intersection_test.js +1 -1
- package/src/engine/graphics/render/layers/RenderLayerUtils.js +1 -1
- package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +8 -7
- package/src/engine/graphics/sh3/LightProbeVolume.js +3 -3
- package/src/engine/graphics/sh3/path_tracer/PathTracer.js +2 -2
- package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +2 -2
- package/src/engine/graphics/sh3/path_tracer/random_in_hemisphere.js +1 -1
- package/src/engine/graphics/sh3/path_tracer/ray_hit_apply_transform.js +1 -1
- package/src/engine/graphics/sh3/path_tracer/ray_reflect.js +1 -1
- package/src/engine/graphics/sh3/prototypeSH3Probe.js +3 -3
- package/src/engine/graphics/sh3/sky/hosek/data.js +3744 -0
- package/src/engine/graphics/sh3/sky/hosek/sky_hosek_compute_irradiance_by_direction.js +10 -3786
- package/src/engine/graphics/sh3/visualise_probe.js +3 -3
- package/src/engine/graphics/shadows/testShadowMapRendering.js +3 -3
- package/src/engine/graphics/texture/atlas/AbstractTextureAtlas.js +1 -1
- package/src/engine/graphics/texture/atlas/AtlasPatch.js +0 -1
- package/src/engine/graphics/texture/atlas/AtlasPatchFlag.js +8 -1
- package/src/engine/graphics/texture/atlas/CachingTextureAtlas.js +25 -0
- package/src/engine/graphics/texture/atlas/CachingTextureAtlas.spec.js +54 -0
- package/src/engine/graphics/texture/atlas/ManagedTextureAtlas.js +101 -160
- package/src/engine/graphics/texture/atlas/TextureAtlas.js +18 -1
- package/src/engine/graphics/texture/sampler/downloadSamplerAsPNG.js +1 -1
- package/src/engine/graphics/texture/sampler/sampler2d_ensure_uint8_RGBA.js +22 -0
- package/src/engine/graphics/texture/sprite/prototypeSpriteCutoutGeometry.js +2 -2
- package/src/engine/graphics/util/projectSphere.js +1 -1
- package/src/engine/input/ecs/controllers/KeyboardCameraController.js +2 -2
- package/src/engine/input/ecs/util/TopDownCameraControllerHelper.js +2 -2
- package/src/engine/intelligence/behavior/composite/ParallelBehavior.spec.js +13 -12
- package/src/engine/navigation/ecs/components/Path.js +1 -1
- package/src/engine/physics/fluid/prototype.js +3 -3
- package/src/engine/physics/mls-mpm/MLS_MPM.js +11 -106
- package/src/engine/reference/v2/Reference.js +6 -2
- package/src/engine/save/storage/JsonStringCodec.js +1 -1
- package/src/engine/save/storage/LocalStorage.js +2 -1
- package/src/engine/sound/ecs/emitter/SoundEmitter.js +7 -7
- package/src/engine/sound/ecs/emitter/SoundTrack.js +6 -6
- package/src/engine/ui/GUIEngine.js +4 -4
- package/src/engine/ui/notification/NotificationManager.js +3 -3
- package/src/generation/filtering/numeric/complex/CellFilterAngleToNormal.js +1 -1
- package/src/generation/grid/generation/road/GridTaskGenerateRoads.js +2 -4
- package/src/generation/markers/debug/visualizeMarkers.js +2 -2
- package/src/generation/markers/prototypeGridCellActionPlaceMarker.js +2 -2
- package/src/generation/placement/action/random/weighted/CellActionSelectWeightedRandom.js +2 -2
- package/src/generation/theme/ThemeEngine.js +2 -2
- package/src/generation/theme/ThemeEngine.spec.js +7 -0
- package/src/view/View.js +21 -13
- package/src/view/elements/ColorPickerView.js +2 -2
- package/src/view/minimap/gl/MarkerGL.js +20 -18
- package/src/view/minimap/gl/MinimapMarkersGL.js +2 -1
- package/editor/tools/FoliagePaintTool.js +0 -168
- package/editor/tools/engine/ToolStateMachine.js +0 -53
- package/src/core/NumberFormat.js +0 -4
- package/src/core/binary/ByteArrayTools.js +0 -137
- package/src/core/binary/NaiveBitSet.js +0 -69
- package/src/core/binary/objects/StandardTypeBuilder.js +0 -126
- package/src/core/binary/serde/JsonSerializer.js +0 -113
- package/src/core/color/rgb2hsv.js +0 -47
- package/src/core/color/rgb_to_YCbCr_uint24.js +0 -16
- package/src/core/fsm/StateMachine.js +0 -440
- package/src/core/fsm/Transition.js +0 -65
- package/src/core/geom/Bezier.js +0 -24
- package/src/core/geom/Bezier.spec.js +0 -16
- package/src/core/math/spline/quadraticCurve.js +0 -11
- package/src/core/math/spline/quadraticCurve.spec.js +0 -13
- package/src/core/primitives/numbers/compareNumbers.js +0 -9
- package/src/engine/graphics/ecs/decal/Decal.js +0 -10
- package/src/engine/graphics/ecs/decal/DecalSystem.js +0 -99
- package/src/engine/graphics/ecs/decal/threejs/DecalGeometry.js +0 -298
- package/src/engine/graphics/ecs/trail/Trail.js +0 -83
- package/src/engine/graphics/ecs/trail/TrailMaterial.js +0 -67
- package/src/engine/graphics/ecs/trail/TrailMaterial2.js +0 -73
- package/src/engine/graphics/ecs/trail/TrailSystem.js +0 -162
- package/src/engine/graphics/ecs/water2/NodeWaterShader1.js +0 -213
- package/src/engine/graphics/ecs/water2/shader/JBWaterShader.js +0 -315
- package/src/engine/graphics/geometry/MikkT/Length.js +0 -10
- package/src/engine/graphics/texture/ImageLoader.js +0 -33
- package/src/engine/graphics/three/DDSLoader.js +0 -286
- package/src/engine/graphics/three/Water2.js +0 -343
- package/src/engine/physics/spring/computeHookeForce.js +0 -9
- package/src/engine/reference/v1/ReferenceManager.js +0 -124
- /package/src/core/color/{hex2rgb.spec.js → hex/hex2rgb.spec.js} +0 -0
- /package/src/core/color/{rgb2hex.spec.js → hex/rgb2hex.spec.js} +0 -0
- /package/src/core/color/{hsv2rgb.spec.js → hsv/hsv2rgb.spec.js} +0 -0
- /package/src/core/color/{rgb_to_kelvin.js → kelvin/rgb_to_kelvin.js} +0 -0
- /package/src/core/color/{linear_to_sRGB.js → sRGB/linear_to_sRGB.js} +0 -0
- /package/src/core/color/{sRGB_to_linear.js → sRGB/sRGB_to_linear.js} +0 -0
- /package/src/core/geom/{m3_determinant.js → mat3/m3_determinant.js} +0 -0
- /package/src/core/geom/{v3_distance.js → vec3/v3_distance.js} +0 -0
- /package/src/core/geom/{v3_distance_above_plane.js → vec3/v3_distance_above_plane.js} +0 -0
- /package/src/core/geom/{v3_distance_above_plane.spec.js → vec3/v3_distance_above_plane.spec.js} +0 -0
- /package/src/core/geom/{v3_distance_sqr.d.ts → vec3/v3_distance_sqr.d.ts} +0 -0
- /package/src/core/geom/{v3_distance_sqr.js → vec3/v3_distance_sqr.js} +0 -0
- /package/src/core/geom/{v3_dot.js → vec3/v3_dot.js} +0 -0
- /package/src/core/geom/{v3_length.js → vec3/v3_length.js} +0 -0
- /package/src/core/geom/{v3_length_sqr.js → vec3/v3_length_sqr.js} +0 -0
- /package/src/core/geom/{v3_slerp.js → vec3/v3_slerp.js} +0 -0
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { quadraticCurve } from "./quadraticCurve.js";
|
|
2
|
-
|
|
3
|
-
test("quadraticCurve", () => {
|
|
4
|
-
expect(quadraticCurve(2, 0.1, 0.2, 3)).toBe(11.3);
|
|
5
|
-
|
|
6
|
-
expect(quadraticCurve(1, -1, -2, -3)).toBe(-3);
|
|
7
|
-
|
|
8
|
-
expect(quadraticCurve(-1, -1, 0, 0)).toBe(-4);
|
|
9
|
-
|
|
10
|
-
expect(quadraticCurve(-1, -1, 1, 0)).toBe(-8);
|
|
11
|
-
|
|
12
|
-
expect(quadraticCurve(-1, 0, 0, 0)).toBe(0);
|
|
13
|
-
});
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { number_compare_ascending } from "./number_compare_ascending.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated use {@link number_compare_ascending} directly
|
|
5
|
-
* @param {number} a
|
|
6
|
-
* @param {number} b
|
|
7
|
-
* @returns {number}
|
|
8
|
-
*/
|
|
9
|
-
export const compareNumbers = number_compare_ascending;
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by Alex on 16/09/2015.
|
|
3
|
-
*/
|
|
4
|
-
import { System } from '../../../ecs/System.js';
|
|
5
|
-
import { Euler as ThreeEuler, MaterialLoader, Mesh as ThreeMesh, Vector3 as ThreeVector3 } from 'three';
|
|
6
|
-
import { Transform } from '../../../ecs/transform/Transform.js';
|
|
7
|
-
import Mesh from '../mesh/Mesh.js';
|
|
8
|
-
import Renderable from '../../../ecs/renderable/Renderable.js';
|
|
9
|
-
import LoadMaterial from "../../material/LoadMaterial.js";
|
|
10
|
-
|
|
11
|
-
import Decal from "./Decal.js";
|
|
12
|
-
import DecalGeometry from "./threejs/DecalGeometry.js";
|
|
13
|
-
import { computeStringHash } from "../../../../core/primitives/strings/computeStringHash.js";
|
|
14
|
-
|
|
15
|
-
const MaterialCache = function () {
|
|
16
|
-
this.materialLoader = new MaterialLoader();
|
|
17
|
-
this.table = {};
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
MaterialCache.prototype.get = function (json) {
|
|
21
|
-
const str = JSON.stringify(json);
|
|
22
|
-
const hash = computeStringHash(str);
|
|
23
|
-
if (this.table.hasOwnProperty(hash)) {
|
|
24
|
-
return this.table[hash];
|
|
25
|
-
} else {
|
|
26
|
-
const options = Object.assign({ assetManager }, json);
|
|
27
|
-
|
|
28
|
-
const material = LoadMaterial(options);
|
|
29
|
-
material.depthTest = true;
|
|
30
|
-
material.depthWrite = false;
|
|
31
|
-
material.polygonOffset = true;
|
|
32
|
-
material.polygonOffsetFactor = -4;
|
|
33
|
-
this.table[hash] = material;
|
|
34
|
-
return material;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
class DecalSystem extends System {
|
|
39
|
-
/**
|
|
40
|
-
*
|
|
41
|
-
* @param scene
|
|
42
|
-
* @param {AssetManager} assetManager
|
|
43
|
-
*/
|
|
44
|
-
constructor(scene, assetManager) {
|
|
45
|
-
super();
|
|
46
|
-
this.scene = scene;
|
|
47
|
-
this.assetManager = assetManager;
|
|
48
|
-
|
|
49
|
-
this.dependencies = [Decal];
|
|
50
|
-
|
|
51
|
-
this.materialCache = new MaterialCache();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
remove(component, entity) {
|
|
55
|
-
this.scene.remove(component.mesh);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
add(component, entity) {
|
|
59
|
-
const meshes = [];
|
|
60
|
-
|
|
61
|
-
const targetModel = this.entityManager.getComponent(component.target, Mesh);
|
|
62
|
-
const targetRenderable = this.entityManager.getComponent(component.target, Renderable);
|
|
63
|
-
|
|
64
|
-
if (targetModel !== null) {
|
|
65
|
-
//TODO implement
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (targetRenderable !== null) {
|
|
69
|
-
processObjectTHREE(targetRenderable.mesh, meshes);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const transform = this.entityManager.getComponent(entity, Transform);
|
|
73
|
-
|
|
74
|
-
const material = this.materialCache.get(component.material);
|
|
75
|
-
|
|
76
|
-
const r = new ThreeEuler();
|
|
77
|
-
r.setFromQuaternion(transform.rotation);
|
|
78
|
-
const size = new ThreeVector3(component.size, component.size, component.size);
|
|
79
|
-
const check = new ThreeVector3(1, 1, 1);
|
|
80
|
-
const geometry = new DecalGeometry(meshes, transform.position, r, size, check);
|
|
81
|
-
const mesh = component.mesh = new ThreeMesh(geometry, material);
|
|
82
|
-
this.scene.add(mesh);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
function processObjectTHREE(object, meshes) {
|
|
88
|
-
if (object.hasOwnProperty("geometry")) {
|
|
89
|
-
meshes.push(object);
|
|
90
|
-
}
|
|
91
|
-
let i = 0;
|
|
92
|
-
const l = object.children.length;
|
|
93
|
-
for (; i < l; i++) {
|
|
94
|
-
const c = object.children[i];
|
|
95
|
-
processObjectTHREE(c, meshes);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export default DecalSystem;
|
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
import { BoxGeometry, Face3, Geometry, Matrix4, Mesh, MeshBasicMaterial, Vector2, Vector3 } from 'three';
|
|
2
|
-
|
|
3
|
-
const DecalVertex = function (v, n) {
|
|
4
|
-
|
|
5
|
-
this.vertex = v;
|
|
6
|
-
this.normal = n;
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
DecalVertex.prototype.clone = function () {
|
|
11
|
-
|
|
12
|
-
return new DecalVertex(this.vertex.clone(), this.normal.clone());
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const DecalGeometry = function (meshes, position, rotation, dimensions, check) {
|
|
17
|
-
|
|
18
|
-
Geometry.call(this);
|
|
19
|
-
|
|
20
|
-
if (check === undefined) check = null;
|
|
21
|
-
check = check || new Vector3(1, 1, 1);
|
|
22
|
-
|
|
23
|
-
this.uvs = [];
|
|
24
|
-
|
|
25
|
-
this.cube = new Mesh(new BoxGeometry(dimensions.x, dimensions.y, dimensions.z), new MeshBasicMaterial());
|
|
26
|
-
this.cube.rotation.set(rotation.x, rotation.y, rotation.z);
|
|
27
|
-
this.cube.position.copy(position);
|
|
28
|
-
this.cube.scale.set(1, 1, 1);
|
|
29
|
-
this.cube.updateMatrix();
|
|
30
|
-
|
|
31
|
-
this.iCubeMatrix = (new Matrix4()).getInverse(this.cube.matrix);
|
|
32
|
-
|
|
33
|
-
this.faceIndices = ['a', 'b', 'c', 'd'];
|
|
34
|
-
|
|
35
|
-
this.clipFace = function (inVertices, plane) {
|
|
36
|
-
|
|
37
|
-
const size = .5 * Math.abs((dimensions.clone()).dot(plane));
|
|
38
|
-
|
|
39
|
-
function clip(v0, v1, p) {
|
|
40
|
-
|
|
41
|
-
const d0 = v0.vertex.dot(p) - size,
|
|
42
|
-
d1 = v1.vertex.dot(p) - size;
|
|
43
|
-
|
|
44
|
-
const s = d0 / (d0 - d1);
|
|
45
|
-
const v = new DecalVertex(
|
|
46
|
-
new Vector3(
|
|
47
|
-
v0.vertex.x + s * (v1.vertex.x - v0.vertex.x),
|
|
48
|
-
v0.vertex.y + s * (v1.vertex.y - v0.vertex.y),
|
|
49
|
-
v0.vertex.z + s * (v1.vertex.z - v0.vertex.z)
|
|
50
|
-
),
|
|
51
|
-
new Vector3(
|
|
52
|
-
v0.normal.x + s * (v1.normal.x - v0.normal.x),
|
|
53
|
-
v0.normal.y + s * (v1.normal.y - v0.normal.y),
|
|
54
|
-
v0.normal.z + s * (v1.normal.z - v0.normal.z)
|
|
55
|
-
)
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
// need to clip more values (texture coordinates)? do it this way:
|
|
59
|
-
//intersectpoint.value = a.value + s*(b.value-a.value);
|
|
60
|
-
|
|
61
|
-
return v;
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (inVertices.length === 0) return [];
|
|
66
|
-
const outVertices = [];
|
|
67
|
-
|
|
68
|
-
for (let j = 0; j < inVertices.length; j += 3) {
|
|
69
|
-
|
|
70
|
-
let v1Out, v2Out, v3Out, total = 0;
|
|
71
|
-
|
|
72
|
-
const d1 = inVertices[j + 0].vertex.dot(plane) - size,
|
|
73
|
-
d2 = inVertices[j + 1].vertex.dot(plane) - size,
|
|
74
|
-
d3 = inVertices[j + 2].vertex.dot(plane) - size;
|
|
75
|
-
|
|
76
|
-
v1Out = d1 > 0;
|
|
77
|
-
v2Out = d2 > 0;
|
|
78
|
-
v3Out = d3 > 0;
|
|
79
|
-
|
|
80
|
-
total = (v1Out ? 1 : 0) + (v2Out ? 1 : 0) + (v3Out ? 1 : 0);
|
|
81
|
-
|
|
82
|
-
switch (total) {
|
|
83
|
-
case 0: {
|
|
84
|
-
|
|
85
|
-
outVertices.push(inVertices[j]);
|
|
86
|
-
outVertices.push(inVertices[j + 1]);
|
|
87
|
-
outVertices.push(inVertices[j + 2]);
|
|
88
|
-
break;
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
case 1: {
|
|
92
|
-
|
|
93
|
-
let nV1, nV2, nV3;
|
|
94
|
-
if (v1Out) {
|
|
95
|
-
|
|
96
|
-
nV1 = inVertices[j + 1];
|
|
97
|
-
nV2 = inVertices[j + 2];
|
|
98
|
-
nV3 = clip(inVertices[j], nV1, plane);
|
|
99
|
-
nV4 = clip(inVertices[j], nV2, plane);
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
if (v2Out) {
|
|
103
|
-
|
|
104
|
-
nV1 = inVertices[j];
|
|
105
|
-
nV2 = inVertices[j + 2];
|
|
106
|
-
nV3 = clip(inVertices[j + 1], nV1, plane);
|
|
107
|
-
nV4 = clip(inVertices[j + 1], nV2, plane);
|
|
108
|
-
|
|
109
|
-
outVertices.push(nV3);
|
|
110
|
-
outVertices.push(nV2.clone());
|
|
111
|
-
outVertices.push(nV1.clone());
|
|
112
|
-
|
|
113
|
-
outVertices.push(nV2.clone());
|
|
114
|
-
outVertices.push(nV3.clone());
|
|
115
|
-
outVertices.push(nV4);
|
|
116
|
-
break;
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
if (v3Out) {
|
|
120
|
-
|
|
121
|
-
nV1 = inVertices[j];
|
|
122
|
-
nV2 = inVertices[j + 1];
|
|
123
|
-
nV3 = clip(inVertices[j + 2], nV1, plane);
|
|
124
|
-
nV4 = clip(inVertices[j + 2], nV2, plane);
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
outVertices.push(nV1.clone());
|
|
129
|
-
outVertices.push(nV2.clone());
|
|
130
|
-
outVertices.push(nV3);
|
|
131
|
-
|
|
132
|
-
outVertices.push(nV4);
|
|
133
|
-
outVertices.push(nV3.clone());
|
|
134
|
-
outVertices.push(nV2.clone());
|
|
135
|
-
|
|
136
|
-
break;
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
case 2: {
|
|
140
|
-
|
|
141
|
-
let nV1, nV2, nV3;
|
|
142
|
-
if (!v1Out) {
|
|
143
|
-
|
|
144
|
-
nV1 = inVertices[j].clone();
|
|
145
|
-
nV2 = clip(nV1, inVertices[j + 1], plane);
|
|
146
|
-
nV3 = clip(nV1, inVertices[j + 2], plane);
|
|
147
|
-
outVertices.push(nV1);
|
|
148
|
-
outVertices.push(nV2);
|
|
149
|
-
outVertices.push(nV3);
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
if (!v2Out) {
|
|
153
|
-
|
|
154
|
-
nV1 = inVertices[j + 1].clone();
|
|
155
|
-
nV2 = clip(nV1, inVertices[j + 2], plane);
|
|
156
|
-
nV3 = clip(nV1, inVertices[j], plane);
|
|
157
|
-
outVertices.push(nV1);
|
|
158
|
-
outVertices.push(nV2);
|
|
159
|
-
outVertices.push(nV3);
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
if (!v3Out) {
|
|
163
|
-
|
|
164
|
-
nV1 = inVertices[j + 2].clone();
|
|
165
|
-
nV2 = clip(nV1, inVertices[j], plane);
|
|
166
|
-
nV3 = clip(nV1, inVertices[j + 1], plane);
|
|
167
|
-
outVertices.push(nV1);
|
|
168
|
-
outVertices.push(nV2);
|
|
169
|
-
outVertices.push(nV3);
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
break;
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
case 3: {
|
|
177
|
-
|
|
178
|
-
break;
|
|
179
|
-
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
return outVertices;
|
|
186
|
-
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
this.pushVertex = function (mesh, vertices, id, n) {
|
|
190
|
-
|
|
191
|
-
const v = mesh.geometry.vertices[id].clone();
|
|
192
|
-
v.applyMatrix4(mesh.matrix);
|
|
193
|
-
v.applyMatrix4(this.iCubeMatrix);
|
|
194
|
-
vertices.push(new DecalVertex(v, n.clone()));
|
|
195
|
-
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
this.computeDecal = function () {
|
|
199
|
-
|
|
200
|
-
let finalVertices = [];
|
|
201
|
-
let f;
|
|
202
|
-
for (let meshIndex = 0; meshIndex < meshes.length; meshIndex++) {
|
|
203
|
-
const mesh = meshes[meshIndex];
|
|
204
|
-
//TODO use bvh frustum intersection test to find candidate faces instead of naive iteration
|
|
205
|
-
let i = 0;
|
|
206
|
-
const iLimit = mesh.geometry.faces.length;
|
|
207
|
-
for (; i < iLimit; i++) {
|
|
208
|
-
|
|
209
|
-
f = mesh.geometry.faces[i];
|
|
210
|
-
let vertices = [];
|
|
211
|
-
|
|
212
|
-
this.pushVertex(mesh, vertices, f[this.faceIndices[0]], f.vertexNormals[0]);
|
|
213
|
-
this.pushVertex(mesh, vertices, f[this.faceIndices[1]], f.vertexNormals[1]);
|
|
214
|
-
this.pushVertex(mesh, vertices, f[this.faceIndices[2]], f.vertexNormals[2]);
|
|
215
|
-
|
|
216
|
-
if (check.x) {
|
|
217
|
-
|
|
218
|
-
vertices = this.clipFace(vertices, new Vector3(1, 0, 0));
|
|
219
|
-
vertices = this.clipFace(vertices, new Vector3(-1, 0, 0));
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
if (check.y) {
|
|
223
|
-
|
|
224
|
-
vertices = this.clipFace(vertices, new Vector3(0, 1, 0));
|
|
225
|
-
vertices = this.clipFace(vertices, new Vector3(0, -1, 0));
|
|
226
|
-
|
|
227
|
-
}
|
|
228
|
-
if (check.z) {
|
|
229
|
-
|
|
230
|
-
vertices = this.clipFace(vertices, new Vector3(0, 0, 1));
|
|
231
|
-
vertices = this.clipFace(vertices, new Vector3(0, 0, -1));
|
|
232
|
-
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
for (let j = 0; j < vertices.length; j++) {
|
|
236
|
-
|
|
237
|
-
const v = vertices[j];
|
|
238
|
-
|
|
239
|
-
this.uvs.push(new Vector2(
|
|
240
|
-
.5 + (v.vertex.x / dimensions.x),
|
|
241
|
-
.5 + (v.vertex.y / dimensions.y)
|
|
242
|
-
));
|
|
243
|
-
|
|
244
|
-
vertices[j].vertex.applyMatrix4(this.cube.matrix);
|
|
245
|
-
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
if (vertices.length === 0) continue;
|
|
249
|
-
|
|
250
|
-
finalVertices = finalVertices.concat(vertices);
|
|
251
|
-
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
for (let k = 0; k < finalVertices.length; k += 3) {
|
|
255
|
-
|
|
256
|
-
this.vertices.push(
|
|
257
|
-
finalVertices[k].vertex,
|
|
258
|
-
finalVertices[k + 1].vertex,
|
|
259
|
-
finalVertices[k + 2].vertex
|
|
260
|
-
);
|
|
261
|
-
|
|
262
|
-
f = new Face3(
|
|
263
|
-
k,
|
|
264
|
-
k + 1,
|
|
265
|
-
k + 2
|
|
266
|
-
);
|
|
267
|
-
f.vertexNormals.push(finalVertices[k].normal);
|
|
268
|
-
f.vertexNormals.push(finalVertices[k + 1].normal);
|
|
269
|
-
f.vertexNormals.push(finalVertices[k + 2].normal);
|
|
270
|
-
|
|
271
|
-
this.faces.push(f);
|
|
272
|
-
|
|
273
|
-
this.faceVertexUvs[0].push([
|
|
274
|
-
this.uvs[k],
|
|
275
|
-
this.uvs[k + 1],
|
|
276
|
-
this.uvs[k + 2]
|
|
277
|
-
]);
|
|
278
|
-
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
this.verticesNeedUpdate = true;
|
|
282
|
-
this.elementsNeedUpdate = true;
|
|
283
|
-
this.morphTargetsNeedUpdate = true;
|
|
284
|
-
this.uvsNeedUpdate = true;
|
|
285
|
-
this.normalsNeedUpdate = true;
|
|
286
|
-
this.colorsNeedUpdate = true;
|
|
287
|
-
this.computeFaceNormals();
|
|
288
|
-
|
|
289
|
-
};
|
|
290
|
-
|
|
291
|
-
this.computeDecal();
|
|
292
|
-
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
DecalGeometry.prototype = Object.create(Geometry.prototype);
|
|
296
|
-
DecalGeometry.prototype.constructor = DecalGeometry;
|
|
297
|
-
|
|
298
|
-
export default DecalGeometry;
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by Alex Goldring on 21.02.2015.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import Vector3 from "../../../../core/geom/Vector3.js";
|
|
6
|
-
|
|
7
|
-
const Trail = function (options) {
|
|
8
|
-
if (options === undefined) {
|
|
9
|
-
options = {};
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
this.lifetime = options.lifetime !== void 0 ? options.lifetime : 5;
|
|
13
|
-
this.textureURL = options.textureURL;
|
|
14
|
-
|
|
15
|
-
this.startColor = options.startColor !== void 0 ? options.startColor : 0xFFFFFF;
|
|
16
|
-
this.endColor = options.endColor !== void 0 ? options.endColor : 0xFFFFFF;
|
|
17
|
-
|
|
18
|
-
this.startOpacity = options.startOpacity !== void 0 ? options.startOpacity : 1;
|
|
19
|
-
this.endOpacity = options.endOpacity !== void 0 ? options.endOpacity : 1;
|
|
20
|
-
|
|
21
|
-
this.startWidth = options.startWidth !== void 0 ? options.startWidth : 1;
|
|
22
|
-
this.endWidth = options.endWidth !== void 0 ? options.endWidth : 1;
|
|
23
|
-
|
|
24
|
-
this.rotation = 0;
|
|
25
|
-
|
|
26
|
-
this.offset = new Vector3();
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
Trail.typeName = 'Trail';
|
|
30
|
-
|
|
31
|
-
Trail.prototype.toJSON = function () {
|
|
32
|
-
return {
|
|
33
|
-
lifetime: this.lifetime,
|
|
34
|
-
textureURL: this.textureURL,
|
|
35
|
-
startColor: this.startColor,
|
|
36
|
-
endColor: this.endColor,
|
|
37
|
-
startOpacity: this.startOpacity,
|
|
38
|
-
endOpacity: this.endOpacity,
|
|
39
|
-
startWidth: this.startWidth,
|
|
40
|
-
endWidth: this.endWidth
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
Trail.prototype.fromJSON = function (json) {
|
|
45
|
-
if (typeof json.lifetime === "number") {
|
|
46
|
-
this.lifetime = json.lifetime;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (typeof json.textureURL === "string") {
|
|
50
|
-
this.textureURL = json.textureURL;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (typeof json.startColor === "number") {
|
|
54
|
-
this.startColor = json.startColor;
|
|
55
|
-
}
|
|
56
|
-
if (typeof json.endColor === "number") {
|
|
57
|
-
this.endColor = json.endColor;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (typeof json.startOpacity === "number") {
|
|
61
|
-
this.startOpacity = json.startOpacity;
|
|
62
|
-
}
|
|
63
|
-
if (typeof json.endOpacity === "number") {
|
|
64
|
-
this.endOpacity = json.endOpacity;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (typeof json.startWidth === "number") {
|
|
68
|
-
this.startWidth = json.startWidth;
|
|
69
|
-
}
|
|
70
|
-
if (typeof json.endWidth === "number") {
|
|
71
|
-
this.endWidth = json.endWidth;
|
|
72
|
-
} else {
|
|
73
|
-
this.endWidth = this.startWidth;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (json.offset !== undefined) {
|
|
77
|
-
this.offset.fromJSON(json.offset);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
Trail.serializable = false;
|
|
82
|
-
|
|
83
|
-
export default Trail;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by Alex Goldring on 22.02.2015.
|
|
3
|
-
*/
|
|
4
|
-
import { Color, DoubleSide, NormalBlending, ShaderMaterial } from 'three';
|
|
5
|
-
|
|
6
|
-
const vertexShader = [
|
|
7
|
-
"attribute float opacity;",
|
|
8
|
-
|
|
9
|
-
"varying float vOpacity;",
|
|
10
|
-
"varying vec2 vUv;",
|
|
11
|
-
|
|
12
|
-
"void main() {",
|
|
13
|
-
|
|
14
|
-
" vOpacity = opacity;",
|
|
15
|
-
" vUv = uv;",
|
|
16
|
-
" gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
|
|
17
|
-
|
|
18
|
-
"}"
|
|
19
|
-
|
|
20
|
-
].join("\n");
|
|
21
|
-
|
|
22
|
-
const fragmentShader = [
|
|
23
|
-
"varying float vOpacity;",
|
|
24
|
-
"varying vec2 vUv;",
|
|
25
|
-
|
|
26
|
-
"uniform vec3 diffuse;",
|
|
27
|
-
"uniform sampler2D texture;",
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"void main() {",
|
|
31
|
-
|
|
32
|
-
" vec4 tcolor = texture2D( texture, vUv );",
|
|
33
|
-
|
|
34
|
-
" gl_FragColor = vec4(tcolor.rgb, tcolor.a*vOpacity);",
|
|
35
|
-
|
|
36
|
-
"}"
|
|
37
|
-
|
|
38
|
-
].join("\n");
|
|
39
|
-
|
|
40
|
-
const TrailMaterial = function () {
|
|
41
|
-
|
|
42
|
-
const uniforms = {
|
|
43
|
-
diffuse: { type: "c", value: new Color(0xFFFFFF) },
|
|
44
|
-
texture: { type: "t", value: null }
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const side = DoubleSide;
|
|
48
|
-
|
|
49
|
-
const shaderMaterial = new ShaderMaterial({
|
|
50
|
-
uniforms: uniforms,
|
|
51
|
-
vertexShader: vertexShader,
|
|
52
|
-
fragmentShader: fragmentShader,
|
|
53
|
-
side: side,
|
|
54
|
-
blending: NormalBlending,
|
|
55
|
-
lights: false,
|
|
56
|
-
depthTest: true,
|
|
57
|
-
depthWrite: false,
|
|
58
|
-
transparent: true
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
shaderMaterial.needsUpdate = true;
|
|
62
|
-
|
|
63
|
-
//shaderMaterial.defaultAttributeValues.tangent = [0, 1, 0];
|
|
64
|
-
return shaderMaterial;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export default TrailMaterial;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by Alex on 26/03/2015.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
"varying vec2 texcoord;";
|
|
6
|
-
"varying vec3 vBC;";
|
|
7
|
-
|
|
8
|
-
let vertexShader = [
|
|
9
|
-
"attribute vec4 last, current, next;",
|
|
10
|
-
"attribute vec3 barycentric;",
|
|
11
|
-
"attribute float texoff;",
|
|
12
|
-
|
|
13
|
-
"uniform mat4 proj, view;",
|
|
14
|
-
"uniform vec2 viewport;",
|
|
15
|
-
"uniform float width;",
|
|
16
|
-
"float pi = 3.141592653589793;",
|
|
17
|
-
|
|
18
|
-
"vec4 transform(vec3 coord){",
|
|
19
|
-
" return proj * view * vec4(coord, 1.0);",
|
|
20
|
-
"}",
|
|
21
|
-
|
|
22
|
-
"vec2 project(vec4 device){",
|
|
23
|
-
" vec3 device_normal = device.xyz/device.w;",
|
|
24
|
-
" vec2 clip_pos = (device_normal*0.5+0.5).xy;",
|
|
25
|
-
" return clip_pos * viewport;",
|
|
26
|
-
"}",
|
|
27
|
-
|
|
28
|
-
"vec4 unproject(vec2 screen, float z, float w){",
|
|
29
|
-
" vec2 clip_pos = screen/viewport;",
|
|
30
|
-
" vec2 device_normal = clip_pos*2.0-1.0;",
|
|
31
|
-
" return vec4(device_normal*w, z, w);",
|
|
32
|
-
"}",
|
|
33
|
-
|
|
34
|
-
"float estimateScale(vec3 position, vec2 sPosition){",
|
|
35
|
-
" vec4 view_pos = view * vec4(position, 1.0);",
|
|
36
|
-
" vec4 scale_pos = view_pos - vec4(normalize(view_pos.xy)*width, 0.0, 0.0);",
|
|
37
|
-
" vec2 screen_scale_pos = project(proj * scale_pos);",
|
|
38
|
-
" return distance(sPosition, screen_scale_pos);",
|
|
39
|
-
"}",
|
|
40
|
-
|
|
41
|
-
"float curvatureCorrection(vec2 a, vec2 b){",
|
|
42
|
-
" float p = a.x*b.y - a.y*b.x;",
|
|
43
|
-
" float c = atan(p, dot(a,b))/pi;",
|
|
44
|
-
" return clamp(c, -1.0, 1.0);",
|
|
45
|
-
"}",
|
|
46
|
-
|
|
47
|
-
"void main(){",
|
|
48
|
-
" vec2 sLast = project(transform(last.xyz));",
|
|
49
|
-
" vec2 sNext = project(transform(next.xyz));",
|
|
50
|
-
|
|
51
|
-
" vec4 dCurrent = transform(current.xyz);",
|
|
52
|
-
" vec2 sCurrent = project(dCurrent);",
|
|
53
|
-
|
|
54
|
-
" vec2 normal1 = normalize(sLast - sCurrent);",
|
|
55
|
-
" vec2 normal2 = normalize(sCurrent - sNext);",
|
|
56
|
-
" vec2 normal = normalize(normal1 + normal2);",
|
|
57
|
-
" float off = current.w;",
|
|
58
|
-
" texcoord = vec2(texoff*0.7, off*0.5+0.5);",
|
|
59
|
-
" vBC = barycentric;",
|
|
60
|
-
" float angle = atan(normal.x, normal.y)+pi*0.5;",
|
|
61
|
-
" vec2 dir = vec2(sin(angle), cos(angle))*off;",
|
|
62
|
-
" float scale = estimateScale(current.xyz, sCurrent);",
|
|
63
|
-
" vec2 pos = sCurrent + dir*scale;",
|
|
64
|
-
|
|
65
|
-
" gl_Position = unproject(pos, dCurrent.z, dCurrent.w);",
|
|
66
|
-
"}"
|
|
67
|
-
];
|
|
68
|
-
let fragmentShader = [
|
|
69
|
-
"uniform sampler2D map;",
|
|
70
|
-
"void main(){",
|
|
71
|
-
" gl_FragColor = texture2D(map, texcoord)*vec4(1.0, 1.0, 1.0, 0.7);",
|
|
72
|
-
"}"
|
|
73
|
-
];
|