@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,5 +1,5 @@
|
|
|
1
1
|
import { SH3VisualisationMaterial } from "./SH3VisualisationMaterial.js";
|
|
2
|
-
import
|
|
2
|
+
import Entity from "../../ecs/Entity.js";
|
|
3
3
|
import { Transform } from "../../ecs/transform/Transform.js";
|
|
4
4
|
import { ShadedGeometry } from "../ecs/mesh-v2/ShadedGeometry.js";
|
|
5
5
|
import { OctahedronBufferGeometry } from "three";
|
|
@@ -12,7 +12,7 @@ import { ShadedGeometryFlags } from "../ecs/mesh-v2/ShadedGeometryFlags.js";
|
|
|
12
12
|
* @param position_offset
|
|
13
13
|
* @param sh
|
|
14
14
|
* @param sh_offset
|
|
15
|
-
* @return {
|
|
15
|
+
* @return {Entity}
|
|
16
16
|
*/
|
|
17
17
|
export function visualise_probe({ size = 1,shadow=false, position, position_offset = 0, sh, sh_offset = 0 }) {
|
|
18
18
|
|
|
@@ -27,7 +27,7 @@ export function visualise_probe({ size = 1,shadow=false, position, position_offs
|
|
|
27
27
|
shadedGeometry.writeFlag(ShadedGeometryFlags.ReceiveShadow,shadow);
|
|
28
28
|
shadedGeometry.writeFlag(ShadedGeometryFlags.CastShadow,shadow);
|
|
29
29
|
|
|
30
|
-
return new
|
|
30
|
+
return new Entity()
|
|
31
31
|
.add(Transform.fromJSON({
|
|
32
32
|
position: {
|
|
33
33
|
x: position[position_offset],
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
import WaterSystem from "../ecs/water/WaterSystem.js";
|
|
34
34
|
import Army from "../../../../../model/game/ecs/component/army/Army.js";
|
|
35
35
|
import Mesh from "../ecs/mesh/Mesh.js";
|
|
36
|
-
import
|
|
36
|
+
import Entity from "../../ecs/Entity.js";
|
|
37
37
|
import { buildCanvasViewFromTexture } from "../render/visibility/hiz/buildCanvasViewFromTexture.js";
|
|
38
38
|
import ViewportPosition from "../../ecs/gui/position/ViewportPosition.js";
|
|
39
39
|
import Vector2 from "../../../core/geom/Vector2.js";
|
|
@@ -143,7 +143,7 @@ function init_shadowmap_preview(engine) {
|
|
|
143
143
|
});
|
|
144
144
|
|
|
145
145
|
|
|
146
|
-
new
|
|
146
|
+
new Entity()
|
|
147
147
|
.add(ViewportPosition.fromJSON({
|
|
148
148
|
offset: new Vector2(10, 10)
|
|
149
149
|
}))
|
|
@@ -165,7 +165,7 @@ async function main(engine) {
|
|
|
165
165
|
|
|
166
166
|
const character = ecd.getAnyComponent(Army);
|
|
167
167
|
|
|
168
|
-
const entity =
|
|
168
|
+
const entity = Entity.readFromDataset(character.entity, ecd);
|
|
169
169
|
|
|
170
170
|
entity.getComponent(Mesh).url = "data/models/Conqueror Mech/Conqueror Mech.gltf";
|
|
171
171
|
|
|
@@ -3,5 +3,12 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const AtlasPatchFlag = {
|
|
5
5
|
Packed: 1,
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Set when patch is drawn into the atlas, cleared when it's not
|
|
8
|
+
*/
|
|
9
|
+
Painted: 2,
|
|
10
|
+
/**
|
|
11
|
+
* Set when patch is added to an atlas and clear when it is removed
|
|
12
|
+
*/
|
|
13
|
+
Attached: 4
|
|
7
14
|
};
|
|
@@ -249,6 +249,24 @@ export class CachingTextureAtlas extends AbstractTextureAtlas {
|
|
|
249
249
|
return -1;
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
+
/**
|
|
253
|
+
*
|
|
254
|
+
* @param {AtlasPatch} patch
|
|
255
|
+
* @returns {number}
|
|
256
|
+
* @private
|
|
257
|
+
*/
|
|
258
|
+
__find_cache_record_index_by_patch(patch) {
|
|
259
|
+
const records = this.__cached_patches;
|
|
260
|
+
const n = records.length;
|
|
261
|
+
for (let i = 0; i < n; i++) {
|
|
262
|
+
if (records[i].patch === patch) {
|
|
263
|
+
return i;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return -1;
|
|
268
|
+
}
|
|
269
|
+
|
|
252
270
|
add(sampler, padding = 4) {
|
|
253
271
|
const existing_patch_index = this.__find_cache_record_index(sampler);
|
|
254
272
|
|
|
@@ -289,6 +307,13 @@ export class CachingTextureAtlas extends AbstractTextureAtlas {
|
|
|
289
307
|
return false;
|
|
290
308
|
}
|
|
291
309
|
|
|
310
|
+
const index = this.__find_cache_record_index_by_patch(patch);
|
|
311
|
+
|
|
312
|
+
if (index !== -1) {
|
|
313
|
+
// already in the cache
|
|
314
|
+
return false;
|
|
315
|
+
}
|
|
316
|
+
|
|
292
317
|
// push to cache, let eviction logic handle the rest
|
|
293
318
|
const record = new PatchRecord();
|
|
294
319
|
|
|
@@ -22,3 +22,57 @@ test("add one", () => {
|
|
|
22
22
|
expect(atlas.contains(patch)).toBe(true);
|
|
23
23
|
|
|
24
24
|
});
|
|
25
|
+
|
|
26
|
+
test("remove one", () => {
|
|
27
|
+
|
|
28
|
+
const atlas = new TextureAtlas();
|
|
29
|
+
const cached = new CachingTextureAtlas({ atlas });
|
|
30
|
+
|
|
31
|
+
const s = Sampler2D.uint8(4, 1, 1);
|
|
32
|
+
|
|
33
|
+
const patch = cached.add(s, 0);
|
|
34
|
+
|
|
35
|
+
expect(cached.remove(patch)).toBe(true);
|
|
36
|
+
|
|
37
|
+
// should stay cached
|
|
38
|
+
expect(atlas.contains(patch)).toBe(true);
|
|
39
|
+
|
|
40
|
+
// cache should tell us that patch is already removed
|
|
41
|
+
expect(cached.remove(patch)).toBe(false);
|
|
42
|
+
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test("add patch that was already in the cache", () => {
|
|
46
|
+
|
|
47
|
+
const atlas = new TextureAtlas();
|
|
48
|
+
const cached = new CachingTextureAtlas({ atlas });
|
|
49
|
+
|
|
50
|
+
const s = Sampler2D.uint8(4, 1, 1);
|
|
51
|
+
|
|
52
|
+
const patch_a = cached.add(s, 0);
|
|
53
|
+
|
|
54
|
+
cached.remove(patch_a);
|
|
55
|
+
|
|
56
|
+
const patch_b = cached.add(s, 0);
|
|
57
|
+
|
|
58
|
+
expect(patch_a).toBe(patch_b);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test("eviction", () => {
|
|
62
|
+
|
|
63
|
+
const atlas = new TextureAtlas(1);
|
|
64
|
+
const cached = new CachingTextureAtlas({ atlas });
|
|
65
|
+
|
|
66
|
+
const sampler_a = Sampler2D.uint8(4, 1, 1);
|
|
67
|
+
|
|
68
|
+
const patch_a = cached.add(sampler_a, 0);
|
|
69
|
+
|
|
70
|
+
cached.remove(patch_a);
|
|
71
|
+
cached.update();
|
|
72
|
+
|
|
73
|
+
const sampler_b = Sampler2D.uint8(4, 1, 1);
|
|
74
|
+
|
|
75
|
+
const patch_b = cached.add(sampler_b, 0);
|
|
76
|
+
|
|
77
|
+
expect(atlas.contains(patch_a)).toBe(false);
|
|
78
|
+
});
|
|
@@ -1,20 +1,56 @@
|
|
|
1
1
|
import { TextureAtlas } from "./TextureAtlas.js";
|
|
2
|
-
import { ReferenceManager } from "../../../reference/v1/ReferenceManager.js";
|
|
3
|
-
import { Sampler2D } from "../sampler/Sampler2D.js";
|
|
4
2
|
import { GameAssetType } from "../../../asset/GameAssetType.js";
|
|
5
|
-
import { HashMap } from "../../../../core/collection/map/HashMap.js";
|
|
6
3
|
import { strictEquals } from "../../../../core/function/Functions.js";
|
|
7
4
|
import { computeStringHash } from "../../../../core/primitives/strings/computeStringHash.js";
|
|
8
|
-
import { copy_Sampler2D_channel_data } from "../sampler/copy_Sampler2D_channel_data.js";
|
|
9
5
|
import { CachingTextureAtlas } from "./CachingTextureAtlas.js";
|
|
6
|
+
import { Reference } from "../../../reference/v2/Reference.js";
|
|
7
|
+
import { LoadingCache } from "../../../../core/cache/LoadingCache.js";
|
|
8
|
+
import { Sampler2D } from "../sampler/Sampler2D.js";
|
|
9
|
+
import { sampler2d_ensure_uint8_RGBA } from "../sampler/sampler2d_ensure_uint8_RGBA.js";
|
|
10
10
|
|
|
11
11
|
export class ManagedAtlas {
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @type {AssetManager|null}
|
|
16
|
+
*/
|
|
17
|
+
#assets = null;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @type {Map<string, Reference>}
|
|
22
|
+
*/
|
|
23
|
+
#references = new Map();
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Pixel padding
|
|
27
|
+
* @type {number}
|
|
28
|
+
*/
|
|
29
|
+
#padding = 4;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @type {LoadingCache<string, AtlasPatch>}
|
|
33
|
+
*/
|
|
34
|
+
#patch_loader;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* @type {Map<string, AtlasPatch>}
|
|
39
|
+
*/
|
|
40
|
+
#url_patch_lookup = new Map();
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @type {Map<AtlasPatch,string[]>}
|
|
44
|
+
*/
|
|
45
|
+
#patch_url_lookup = new Map();
|
|
46
|
+
|
|
12
47
|
/**
|
|
13
48
|
*
|
|
14
49
|
* @param {AssetManager} assetManager
|
|
15
50
|
* @constructor
|
|
16
51
|
*/
|
|
17
52
|
constructor(assetManager) {
|
|
53
|
+
this.#assets = assetManager;
|
|
18
54
|
|
|
19
55
|
/**
|
|
20
56
|
* pre-allocate space on the atlas to avoid some initial re-sizing
|
|
@@ -22,16 +58,8 @@ export class ManagedAtlas {
|
|
|
22
58
|
*/
|
|
23
59
|
const atlas = new TextureAtlas(64);
|
|
24
60
|
|
|
25
|
-
/**
|
|
26
|
-
*
|
|
27
|
-
* @type {WeakMap<string, Sampler2D>}
|
|
28
|
-
* @private
|
|
29
|
-
*/
|
|
30
|
-
this.__cached_samplers = new Map();
|
|
31
|
-
const cached_samplers = this.__cached_samplers;
|
|
32
61
|
|
|
33
|
-
|
|
34
|
-
this.__caching_atlas = cached_atlas;
|
|
62
|
+
this.__caching_atlas = new CachingTextureAtlas({ atlas });
|
|
35
63
|
|
|
36
64
|
/**
|
|
37
65
|
*
|
|
@@ -39,177 +67,90 @@ export class ManagedAtlas {
|
|
|
39
67
|
*/
|
|
40
68
|
this.atlas = atlas;
|
|
41
69
|
|
|
42
|
-
|
|
43
|
-
*
|
|
44
|
-
* @type {HashMap<String, AtlasPatch>}
|
|
45
|
-
*/
|
|
46
|
-
const activePatches = new HashMap({
|
|
47
|
-
keyHashFunction: computeStringHash,
|
|
48
|
-
keyEqualityFunction: strictEquals
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* @private
|
|
53
|
-
* @type {HashMap<String, AtlasPatch>}
|
|
54
|
-
*/
|
|
55
|
-
this.patchesActive = activePatches;
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Automatically update TextureAtlas
|
|
59
|
-
* @type {boolean}
|
|
60
|
-
*/
|
|
61
|
-
this.autoUpdate = true;
|
|
62
|
-
|
|
63
|
-
this.rebuildDelay = 200; //in milliseconds
|
|
70
|
+
atlas.on.removed.add(this.#remove_from_lookup, this);
|
|
64
71
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
72
|
+
this.#patch_loader = new LoadingCache({
|
|
73
|
+
keyHashFunction: computeStringHash,
|
|
74
|
+
keyEqualityFunction: strictEquals,
|
|
75
|
+
load: async (url) => {
|
|
76
|
+
const sampler = await this.#resolve_texture(url);
|
|
69
77
|
|
|
70
|
-
|
|
71
|
-
const timeNow = Date.now();
|
|
72
|
-
const timeElapsed = timeNow - lastRebuildTime;
|
|
78
|
+
const patch = this.__caching_atlas.add(sampler, this.#padding);
|
|
73
79
|
|
|
74
|
-
|
|
75
|
-
atlas.update();
|
|
80
|
+
this.#add_to_lookup(url, patch);
|
|
76
81
|
|
|
77
|
-
|
|
82
|
+
return patch;
|
|
78
83
|
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
*
|
|
83
|
-
* @param {string} url
|
|
84
|
-
* @returns {Promise<AtlasPatch>}
|
|
85
|
-
*/
|
|
86
|
-
function creator(url) {
|
|
87
|
-
return new Promise(function (resolve, reject) {
|
|
88
|
-
|
|
89
|
-
let patch = activePatches.get(url);
|
|
90
|
-
|
|
91
|
-
if (patch !== undefined) {
|
|
92
|
-
resolve(patch);
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const cached_sampler = cached_samplers.get(url);
|
|
97
|
-
|
|
98
|
-
if (cached_sampler !== undefined) {
|
|
99
|
-
patch = cached_atlas.add(cached_sampler);
|
|
100
|
-
resolve(patch);
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
*
|
|
106
|
-
* @param {Asset} asset
|
|
107
|
-
*/
|
|
108
|
-
function onLoad(asset) {
|
|
109
|
-
|
|
110
|
-
//since load happens asynchronously, we need to make sure that the patch is still required
|
|
111
|
-
const refCount = referenceManager.getCount(url);
|
|
112
|
-
|
|
113
|
-
if (refCount === 0) {
|
|
114
|
-
//no longer part of active reference set, ignore
|
|
115
|
-
//this happens when a patch is requested and removed before it is loaded
|
|
116
|
-
reject(`'${url}' is no longer part of active reference set`);
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const image = asset.create();
|
|
121
|
-
|
|
122
|
-
const source = new Sampler2D(image.data, image.itemSize, image.width, image.height);
|
|
123
|
-
//assert.equal(atlas.patches.filter(p => p.sampler.data === image.data).length, 0, "Atlas already contains this asset data");
|
|
124
|
-
|
|
125
|
-
//build sampler
|
|
126
|
-
let sampler;
|
|
127
|
-
|
|
128
|
-
if (source.itemSize !== 4) {
|
|
129
|
-
// source image is not in RGBA layout, resample
|
|
130
|
-
sampler = Sampler2D.uint8(4, image.width, image.height);
|
|
131
|
-
copy_Sampler2D_channel_data(source, sampler)
|
|
132
|
-
} else {
|
|
133
|
-
sampler = source;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
cached_samplers.set(url, sampler);
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const patch = cached_atlas.add(sampler);
|
|
140
|
-
|
|
141
|
-
//record active patch
|
|
142
|
-
activePatches.set(url, patch);
|
|
143
|
-
|
|
144
|
-
counterLoadingAssets--;
|
|
145
|
-
|
|
146
|
-
if (self.autoUpdate) {
|
|
147
|
-
tryRebuild();
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// console.warn(`ManagedAtlas: Loaded patch. size: ${image.data.length}, width: ${image.width}, height: ${image.height}, url: ${url}`, atlas);
|
|
151
|
-
|
|
152
|
-
resolve(patch);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
function onFailure(error) {
|
|
156
|
-
counterLoadingAssets--;
|
|
157
|
-
|
|
158
|
-
reject(error);
|
|
159
|
-
}
|
|
160
|
-
|
|
84
|
+
});
|
|
85
|
+
}
|
|
161
86
|
|
|
162
|
-
|
|
87
|
+
/**
|
|
88
|
+
*
|
|
89
|
+
* @param {AtlasPatch} patch
|
|
90
|
+
*/
|
|
91
|
+
#remove_from_lookup(patch) {
|
|
92
|
+
const urls = this.#patch_url_lookup.get(patch);
|
|
163
93
|
|
|
164
|
-
|
|
94
|
+
for (let i = 0; i < urls.length; i++) {
|
|
95
|
+
const url = urls[i];
|
|
165
96
|
|
|
166
|
-
|
|
97
|
+
this.#url_patch_lookup.delete(url);
|
|
167
98
|
}
|
|
99
|
+
}
|
|
168
100
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
promise.then(function (patch) {
|
|
176
|
-
//it is possible that promise is resolved after patch has already been removed from the Atlas, so we first check
|
|
101
|
+
/**
|
|
102
|
+
*
|
|
103
|
+
* @param {string} url
|
|
104
|
+
* @param {AtlasPatch} patch
|
|
105
|
+
*/
|
|
106
|
+
#add_to_lookup(url, patch) {
|
|
177
107
|
|
|
178
|
-
|
|
179
|
-
//remove from active
|
|
180
|
-
activePatches.delete(url);
|
|
108
|
+
this.#url_patch_lookup.set(url, patch);
|
|
181
109
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
110
|
+
let urls = this.#patch_url_lookup.get(patch);
|
|
111
|
+
if (urls === undefined) {
|
|
112
|
+
urls = [];
|
|
113
|
+
this.#patch_url_lookup.set(patch, urls);
|
|
185
114
|
}
|
|
115
|
+
urls.push(url);
|
|
116
|
+
}
|
|
186
117
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
118
|
+
/**
|
|
119
|
+
*
|
|
120
|
+
* @param {string} url
|
|
121
|
+
* @returns {Promise<Sampler2D>}
|
|
122
|
+
*/
|
|
123
|
+
async #resolve_texture(url) {
|
|
124
|
+
const asset = await this.#assets.promise(url, GameAssetType.Image);
|
|
125
|
+
const source = asset.create();
|
|
192
126
|
|
|
193
|
-
|
|
194
|
-
*
|
|
195
|
-
* @type {ReferenceManager<String, Promise<AtlasPatch>>}
|
|
196
|
-
*/
|
|
197
|
-
this.references = referenceManager;
|
|
127
|
+
return sampler2d_ensure_uint8_RGBA(source);
|
|
198
128
|
}
|
|
199
129
|
|
|
200
130
|
reset() {
|
|
201
|
-
this
|
|
131
|
+
this.#references.clear();
|
|
202
132
|
this.__caching_atlas.reset();
|
|
203
|
-
this.
|
|
133
|
+
this.#url_patch_lookup.clear();
|
|
204
134
|
}
|
|
205
135
|
|
|
206
136
|
/**
|
|
207
137
|
*
|
|
208
138
|
* @param {string} key
|
|
209
|
-
* @returns {Promise<AtlasPatch
|
|
139
|
+
* @returns {Promise<Reference<AtlasPatch>>}
|
|
210
140
|
*/
|
|
211
|
-
acquire(
|
|
212
|
-
|
|
141
|
+
async acquire(url) {
|
|
142
|
+
const reference = new Reference();
|
|
143
|
+
|
|
144
|
+
let patch = this.#url_patch_lookup.get(url);
|
|
145
|
+
|
|
146
|
+
if (patch === undefined) {
|
|
147
|
+
// patch is not active, need to load it
|
|
148
|
+
patch = await this.#patch_loader.get(url);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
reference.bind(patch);
|
|
152
|
+
|
|
153
|
+
return reference;
|
|
213
154
|
}
|
|
214
155
|
|
|
215
156
|
/**
|
|
@@ -217,6 +158,6 @@ export class ManagedAtlas {
|
|
|
217
158
|
* @param {string} key
|
|
218
159
|
*/
|
|
219
160
|
release(key) {
|
|
220
|
-
|
|
161
|
+
throw new Error('Method is deprecated, use "Reference.release" instead');
|
|
221
162
|
}
|
|
222
163
|
}
|
|
@@ -66,7 +66,11 @@ export class TextureAtlas extends AbstractTextureAtlas {
|
|
|
66
66
|
this.packer = new MaxRectanglesPacker(size, size);
|
|
67
67
|
|
|
68
68
|
this.on = {
|
|
69
|
-
painted: new Signal()
|
|
69
|
+
painted: new Signal(),
|
|
70
|
+
/**
|
|
71
|
+
* @type {Signal<AtlasPatch, Sampler2D>}
|
|
72
|
+
*/
|
|
73
|
+
removed: new Signal()
|
|
70
74
|
};
|
|
71
75
|
|
|
72
76
|
/**
|
|
@@ -264,6 +268,7 @@ export class TextureAtlas extends AbstractTextureAtlas {
|
|
|
264
268
|
|
|
265
269
|
assert.notNull(sampler, 'sampler');
|
|
266
270
|
assert.defined(sampler, 'sampler');
|
|
271
|
+
assert.equal(sampler.isSampler2D, true, 'sampler.isSampler2D !== true');
|
|
267
272
|
|
|
268
273
|
assert.isNonNegativeInteger(padding, 'padding');
|
|
269
274
|
|
|
@@ -276,6 +281,9 @@ export class TextureAtlas extends AbstractTextureAtlas {
|
|
|
276
281
|
patch.size.set(sampler.width, sampler.height);
|
|
277
282
|
patch.padding = padding;
|
|
278
283
|
|
|
284
|
+
// mark patch as belonging to an atlas
|
|
285
|
+
patch.setFlag(AtlasPatchFlag.Attached);
|
|
286
|
+
|
|
279
287
|
const padding2 = padding * 2;
|
|
280
288
|
|
|
281
289
|
patch.packing.set(0, 0, sampler.width + padding2, sampler.height + padding2);
|
|
@@ -324,6 +332,15 @@ export class TextureAtlas extends AbstractTextureAtlas {
|
|
|
324
332
|
this.packer.remove(patch.packing);
|
|
325
333
|
}
|
|
326
334
|
|
|
335
|
+
// clear flags
|
|
336
|
+
patch.clearFlag(
|
|
337
|
+
AtlasPatchFlag.Attached
|
|
338
|
+
| AtlasPatchFlag.Packed
|
|
339
|
+
| AtlasPatchFlag.Painted
|
|
340
|
+
);
|
|
341
|
+
|
|
342
|
+
this.on.removed.send2(patch, patch.sampler);
|
|
343
|
+
|
|
327
344
|
return true;
|
|
328
345
|
}
|
|
329
346
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Sampler2D } from "./Sampler2D.js";
|
|
2
|
+
import { sampler2d_to_uint8_RGBA } from "./sampler2d_to_uint8_RGBA.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param {Sampler2D} input
|
|
7
|
+
* @returns {Sampler2D}
|
|
8
|
+
*/
|
|
9
|
+
export function sampler2d_ensure_uint8_RGBA(input) {
|
|
10
|
+
if (
|
|
11
|
+
input.itemSize === 4
|
|
12
|
+
&& (input.data.constructor === Uint8Array || input.data.constructor === Uint8ClampedArray)
|
|
13
|
+
) {
|
|
14
|
+
return input;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const resampled = Sampler2D.uint8(4, input.width, input.height);
|
|
18
|
+
|
|
19
|
+
sampler2d_to_uint8_RGBA(resampled, input);
|
|
20
|
+
|
|
21
|
+
return resampled;
|
|
22
|
+
}
|
|
@@ -2,7 +2,7 @@ import { EngineHarness } from "../../../EngineHarness.js";
|
|
|
2
2
|
import GUIElementSystem from "../../../ecs/gui/GUIElementSystem.js";
|
|
3
3
|
import { ImageRGBADataLoader } from "../../../asset/loaders/image/ImageRGBADataLoader.js";
|
|
4
4
|
import EmptyView from "../../../../view/elements/EmptyView.js";
|
|
5
|
-
import
|
|
5
|
+
import Entity from "../../../ecs/Entity.js";
|
|
6
6
|
import GUIElement from "../../../ecs/gui/GUIElement.js";
|
|
7
7
|
import ViewportPositionSystem from "../../../ecs/gui/position/ViewportPositionSystem.js";
|
|
8
8
|
import { CanvasView } from "../../../../view/elements/CanvasView.js";
|
|
@@ -193,7 +193,7 @@ async function main(engine) {
|
|
|
193
193
|
|
|
194
194
|
vContainer.addChild(vOptimalPoly);
|
|
195
195
|
|
|
196
|
-
new
|
|
196
|
+
new Entity()
|
|
197
197
|
.add(GUIElement.fromView(vContainer))
|
|
198
198
|
.add(new ViewportPosition({
|
|
199
199
|
offset: new Vector2(100, 100)
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import Vector2 from '../../../../core/geom/Vector2.js';
|
|
7
7
|
import Script from '../../../ecs/components/Script.js';
|
|
8
|
-
import
|
|
8
|
+
import Entity from '../../../ecs/Entity.js';
|
|
9
9
|
import InputController from '../components/InputController.js';
|
|
10
10
|
import { assert } from "../../../../core/assert.js";
|
|
11
11
|
import { Tag } from "../../../ecs/components/Tag.js";
|
|
@@ -105,7 +105,7 @@ class KeyboardCameraController {
|
|
|
105
105
|
controller.target.add(v3);
|
|
106
106
|
});
|
|
107
107
|
|
|
108
|
-
const builder = new
|
|
108
|
+
const builder = new Entity();
|
|
109
109
|
|
|
110
110
|
this.builder = builder
|
|
111
111
|
.add(inputController)
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { Transform } from '../../../ecs/transform/Transform.js';
|
|
5
5
|
import Renderable from '../../../ecs/renderable/Renderable.js';
|
|
6
6
|
import Vector3 from '../../../../core/geom/Vector3.js';
|
|
7
|
-
import
|
|
7
|
+
import Entity from '../../../ecs/Entity.js';
|
|
8
8
|
import { Group as ThreeGroup, Matrix4 as ThreeMatrix4, Mesh as ThreeMesh, MeshLambertMaterial } from 'three';
|
|
9
9
|
|
|
10
10
|
|
|
@@ -62,7 +62,7 @@ const TopDownCameraControllerHelper = function (targetController, targetTransfor
|
|
|
62
62
|
group.add(tMarkerTo);
|
|
63
63
|
|
|
64
64
|
|
|
65
|
-
const builder = new
|
|
65
|
+
const builder = new Entity();
|
|
66
66
|
const transform = new Transform();
|
|
67
67
|
builder.add(new Renderable(group))
|
|
68
68
|
.add(transform);
|