samcan 0.0.2 → 0.1.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/{license → LICENSE} +3 -1
- package/README.md +3 -0
- package/dist/camera/index.cjs +370 -0
- package/dist/camera/index.d.cts +54 -0
- package/dist/camera/index.d.ts +54 -0
- package/dist/camera/index.js +70 -0
- package/dist/document/index.cjs +735 -0
- package/dist/document/index.d.cts +174 -0
- package/dist/document/index.d.ts +174 -0
- package/dist/document/index.js +161 -0
- package/dist/editor/index.cjs +5007 -0
- package/dist/editor/index.d.cts +374 -0
- package/dist/editor/index.d.ts +374 -0
- package/dist/editor/index.js +2401 -0
- package/dist/engine/index.cjs +3752 -0
- package/dist/engine/index.d.cts +183 -0
- package/dist/engine/index.d.ts +183 -0
- package/dist/engine/index.js +111 -0
- package/dist/index.cjs +8899 -0
- package/dist/index.d.cts +962 -0
- package/dist/index.d.ts +962 -46
- package/dist/index.js +1008 -49
- package/dist/math/index.cjs +2230 -0
- package/dist/math/index.d.cts +302 -0
- package/dist/math/index.d.ts +302 -0
- package/dist/math/index.js +1109 -0
- package/dist/renderer/index.cjs +1865 -0
- package/dist/renderer/index.d.cts +91 -0
- package/dist/renderer/index.d.ts +91 -0
- package/dist/renderer/index.js +89 -0
- package/dist/shared/chunk-35pkr0zs.js +110 -0
- package/dist/shared/chunk-7sr7q84y.js +80 -0
- package/dist/shared/chunk-87399bz7.js +89 -0
- package/dist/shared/chunk-8ynnz57m.js +129 -0
- package/dist/shared/chunk-d6gxvapt.js +500 -0
- package/dist/shared/chunk-hewznwbd.js +305 -0
- package/dist/shared/chunk-jdvrd5tv.js +623 -0
- package/dist/shared/chunk-rvag1j46.js +461 -0
- package/dist/shared/chunk-rzxyjwk8.js +397 -0
- package/dist/shared/chunk-s3qdcmcq.js +1392 -0
- package/dist/shared/chunk-v53jprrn.js +68 -0
- package/dist/shared/chunk-wa3772hp.js +117 -0
- package/dist/spatial/index.cjs +954 -0
- package/dist/spatial/index.d.cts +136 -0
- package/dist/spatial/index.d.ts +136 -0
- package/dist/spatial/index.js +301 -0
- package/dist/stroke/index.cjs +1010 -0
- package/dist/stroke/index.d.cts +143 -0
- package/dist/stroke/index.d.ts +143 -0
- package/dist/stroke/index.js +343 -0
- package/package.json +122 -58
- package/dist/bundle.js +0 -5888
- package/dist/core/animation/animationruntime.d.ts +0 -238
- package/dist/core/animation/animationruntime.d.ts.map +0 -1
- package/dist/core/animation/animationruntime.js +0 -530
- package/dist/core/animation/animationruntime.js.map +0 -1
- package/dist/core/animation/animationstate.d.ts +0 -85
- package/dist/core/animation/animationstate.d.ts.map +0 -1
- package/dist/core/animation/animationstate.js +0 -119
- package/dist/core/animation/animationstate.js.map +0 -1
- package/dist/core/animation/animationtrack.d.ts +0 -55
- package/dist/core/animation/animationtrack.d.ts.map +0 -1
- package/dist/core/animation/animationtrack.js +0 -185
- package/dist/core/animation/animationtrack.js.map +0 -1
- package/dist/core/animation/easing.d.ts +0 -80
- package/dist/core/animation/easing.d.ts.map +0 -1
- package/dist/core/animation/easing.js +0 -126
- package/dist/core/animation/easing.js.map +0 -1
- package/dist/core/animation/index.d.ts +0 -11
- package/dist/core/animation/index.d.ts.map +0 -1
- package/dist/core/animation/index.js +0 -10
- package/dist/core/animation/index.js.map +0 -1
- package/dist/core/animation/interpolator.d.ts +0 -82
- package/dist/core/animation/interpolator.d.ts.map +0 -1
- package/dist/core/animation/interpolator.js +0 -108
- package/dist/core/animation/interpolator.js.map +0 -1
- package/dist/core/animation/keyframe.d.ts +0 -52
- package/dist/core/animation/keyframe.d.ts.map +0 -1
- package/dist/core/animation/keyframe.js +0 -65
- package/dist/core/animation/keyframe.js.map +0 -1
- package/dist/core/animation/logger.d.ts +0 -8
- package/dist/core/animation/logger.d.ts.map +0 -1
- package/dist/core/animation/logger.js +0 -20
- package/dist/core/animation/logger.js.map +0 -1
- package/dist/core/animation/statemachine.d.ts +0 -178
- package/dist/core/animation/statemachine.d.ts.map +0 -1
- package/dist/core/animation/statemachine.js +0 -378
- package/dist/core/animation/statemachine.js.map +0 -1
- package/dist/core/animation/statetransition.d.ts +0 -142
- package/dist/core/animation/statetransition.d.ts.map +0 -1
- package/dist/core/animation/statetransition.js +0 -189
- package/dist/core/animation/statetransition.js.map +0 -1
- package/dist/core/animation/timeline.d.ts +0 -62
- package/dist/core/animation/timeline.d.ts.map +0 -1
- package/dist/core/animation/timeline.js +0 -102
- package/dist/core/animation/timeline.js.map +0 -1
- package/dist/core/api.d.ts +0 -245
- package/dist/core/api.d.ts.map +0 -1
- package/dist/core/api.js +0 -369
- package/dist/core/api.js.map +0 -1
- package/dist/core/asset/assetmanager.d.ts +0 -196
- package/dist/core/asset/assetmanager.d.ts.map +0 -1
- package/dist/core/asset/assetmanager.js +0 -502
- package/dist/core/asset/assetmanager.js.map +0 -1
- package/dist/core/asset/index.d.ts +0 -3
- package/dist/core/asset/index.d.ts.map +0 -1
- package/dist/core/asset/index.js +0 -3
- package/dist/core/asset/index.js.map +0 -1
- package/dist/core/asset/types.d.ts +0 -36
- package/dist/core/asset/types.d.ts.map +0 -1
- package/dist/core/asset/types.js +0 -1
- package/dist/core/asset/types.js.map +0 -1
- package/dist/core/command/basecommand.d.ts +0 -29
- package/dist/core/command/basecommand.d.ts.map +0 -1
- package/dist/core/command/basecommand.js +0 -36
- package/dist/core/command/basecommand.js.map +0 -1
- package/dist/core/command/command.d.ts +0 -55
- package/dist/core/command/command.d.ts.map +0 -1
- package/dist/core/command/command.js +0 -1
- package/dist/core/command/command.js.map +0 -1
- package/dist/core/command/commandhistory.d.ts +0 -76
- package/dist/core/command/commandhistory.d.ts.map +0 -1
- package/dist/core/command/commandhistory.js +0 -122
- package/dist/core/command/commandhistory.js.map +0 -1
- package/dist/core/command/editorcommands.d.ts +0 -108
- package/dist/core/command/editorcommands.d.ts.map +0 -1
- package/dist/core/command/editorcommands.js +0 -274
- package/dist/core/command/editorcommands.js.map +0 -1
- package/dist/core/command/index.d.ts +0 -5
- package/dist/core/command/index.d.ts.map +0 -1
- package/dist/core/command/index.js +0 -5
- package/dist/core/command/index.js.map +0 -1
- package/dist/core/editor/events/emitter.d.ts +0 -45
- package/dist/core/editor/events/emitter.d.ts.map +0 -1
- package/dist/core/editor/events/emitter.js +0 -88
- package/dist/core/editor/events/emitter.js.map +0 -1
- package/dist/core/error/animationerror.d.ts +0 -27
- package/dist/core/error/animationerror.d.ts.map +0 -1
- package/dist/core/error/animationerror.js +0 -41
- package/dist/core/error/animationerror.js.map +0 -1
- package/dist/core/error/asseterror.d.ts +0 -32
- package/dist/core/error/asseterror.d.ts.map +0 -1
- package/dist/core/error/asseterror.js +0 -48
- package/dist/core/error/asseterror.js.map +0 -1
- package/dist/core/error/index.d.ts +0 -7
- package/dist/core/error/index.d.ts.map +0 -1
- package/dist/core/error/index.js +0 -7
- package/dist/core/error/index.js.map +0 -1
- package/dist/core/error/pluginerror.d.ts +0 -22
- package/dist/core/error/pluginerror.d.ts.map +0 -1
- package/dist/core/error/pluginerror.js +0 -33
- package/dist/core/error/pluginerror.js.map +0 -1
- package/dist/core/error/renderererror.d.ts +0 -26
- package/dist/core/error/renderererror.d.ts.map +0 -1
- package/dist/core/error/renderererror.js +0 -40
- package/dist/core/error/renderererror.js.map +0 -1
- package/dist/core/error/samcanerror.d.ts +0 -72
- package/dist/core/error/samcanerror.d.ts.map +0 -1
- package/dist/core/error/samcanerror.js +0 -108
- package/dist/core/error/samcanerror.js.map +0 -1
- package/dist/core/error/serializationerror.d.ts +0 -31
- package/dist/core/error/serializationerror.d.ts.map +0 -1
- package/dist/core/error/serializationerror.js +0 -46
- package/dist/core/error/serializationerror.js.map +0 -1
- package/dist/core/index.d.ts +0 -12
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -12
- package/dist/core/index.js.map +0 -1
- package/dist/core/math/color.d.ts +0 -56
- package/dist/core/math/color.d.ts.map +0 -1
- package/dist/core/math/color.js +0 -125
- package/dist/core/math/color.js.map +0 -1
- package/dist/core/math/index.d.ts +0 -14
- package/dist/core/math/index.d.ts.map +0 -1
- package/dist/core/math/index.js +0 -14
- package/dist/core/math/index.js.map +0 -1
- package/dist/core/math/matrix.d.ts +0 -101
- package/dist/core/math/matrix.d.ts.map +0 -1
- package/dist/core/math/matrix.js +0 -177
- package/dist/core/math/matrix.js.map +0 -1
- package/dist/core/math/paint.d.ts +0 -104
- package/dist/core/math/paint.d.ts.map +0 -1
- package/dist/core/math/paint.js +0 -204
- package/dist/core/math/paint.js.map +0 -1
- package/dist/core/math/path/index.d.ts +0 -94
- package/dist/core/math/path/index.d.ts.map +0 -1
- package/dist/core/math/path/index.js +0 -180
- package/dist/core/math/path/index.js.map +0 -1
- package/dist/core/math/path/operations.d.ts +0 -38
- package/dist/core/math/path/operations.d.ts.map +0 -1
- package/dist/core/math/path/operations.js +0 -149
- package/dist/core/math/path/operations.js.map +0 -1
- package/dist/core/math/pool.d.ts +0 -54
- package/dist/core/math/pool.d.ts.map +0 -1
- package/dist/core/math/pool.js +0 -97
- package/dist/core/math/pool.js.map +0 -1
- package/dist/core/math/pools.d.ts +0 -29
- package/dist/core/math/pools.d.ts.map +0 -1
- package/dist/core/math/pools.js +0 -50
- package/dist/core/math/pools.js.map +0 -1
- package/dist/core/math/rectangle.d.ts +0 -68
- package/dist/core/math/rectangle.d.ts.map +0 -1
- package/dist/core/math/rectangle.js +0 -124
- package/dist/core/math/rectangle.js.map +0 -1
- package/dist/core/math/utils.d.ts +0 -68
- package/dist/core/math/utils.d.ts.map +0 -1
- package/dist/core/math/utils.js +0 -110
- package/dist/core/math/utils.js.map +0 -1
- package/dist/core/math/vector2.d.ts +0 -85
- package/dist/core/math/vector2.d.ts.map +0 -1
- package/dist/core/math/vector2.js +0 -134
- package/dist/core/math/vector2.js.map +0 -1
- package/dist/core/plugin/animationcontroller.d.ts +0 -43
- package/dist/core/plugin/animationcontroller.d.ts.map +0 -1
- package/dist/core/plugin/animationcontroller.js +0 -11
- package/dist/core/plugin/animationcontroller.js.map +0 -1
- package/dist/core/plugin/index.d.ts +0 -6
- package/dist/core/plugin/index.d.ts.map +0 -1
- package/dist/core/plugin/index.js +0 -4
- package/dist/core/plugin/index.js.map +0 -1
- package/dist/core/plugin/plugin.d.ts +0 -53
- package/dist/core/plugin/plugin.d.ts.map +0 -1
- package/dist/core/plugin/plugin.js +0 -29
- package/dist/core/plugin/plugin.js.map +0 -1
- package/dist/core/plugin/pluginregistry.d.ts +0 -71
- package/dist/core/plugin/pluginregistry.d.ts.map +0 -1
- package/dist/core/plugin/pluginregistry.js +0 -143
- package/dist/core/plugin/pluginregistry.js.map +0 -1
- package/dist/core/renderer/batchmanager.d.ts +0 -68
- package/dist/core/renderer/batchmanager.d.ts.map +0 -1
- package/dist/core/renderer/batchmanager.js +0 -82
- package/dist/core/renderer/batchmanager.js.map +0 -1
- package/dist/core/renderer/canvas2drenderer.d.ts +0 -139
- package/dist/core/renderer/canvas2drenderer.d.ts.map +0 -1
- package/dist/core/renderer/canvas2drenderer.js +0 -499
- package/dist/core/renderer/canvas2drenderer.js.map +0 -1
- package/dist/core/renderer/dirtyregionmanager.d.ts +0 -54
- package/dist/core/renderer/dirtyregionmanager.d.ts.map +0 -1
- package/dist/core/renderer/dirtyregionmanager.js +0 -129
- package/dist/core/renderer/dirtyregionmanager.js.map +0 -1
- package/dist/core/renderer/index.d.ts +0 -8
- package/dist/core/renderer/index.d.ts.map +0 -1
- package/dist/core/renderer/index.js +0 -6
- package/dist/core/renderer/index.js.map +0 -1
- package/dist/core/renderer/renderer.d.ts +0 -154
- package/dist/core/renderer/renderer.d.ts.map +0 -1
- package/dist/core/renderer/renderer.js +0 -1
- package/dist/core/renderer/renderer.js.map +0 -1
- package/dist/core/renderer/rendererfactory.d.ts +0 -66
- package/dist/core/renderer/rendererfactory.d.ts.map +0 -1
- package/dist/core/renderer/rendererfactory.js +0 -219
- package/dist/core/renderer/rendererfactory.js.map +0 -1
- package/dist/core/renderer/webglrenderer.d.ts +0 -185
- package/dist/core/renderer/webglrenderer.d.ts.map +0 -1
- package/dist/core/renderer/webglrenderer.js +0 -1007
- package/dist/core/renderer/webglrenderer.js.map +0 -1
- package/dist/core/scene/index.d.ts +0 -4
- package/dist/core/scene/index.d.ts.map +0 -1
- package/dist/core/scene/index.js +0 -4
- package/dist/core/scene/index.js.map +0 -1
- package/dist/core/scene/node.d.ts +0 -162
- package/dist/core/scene/node.d.ts.map +0 -1
- package/dist/core/scene/node.js +0 -402
- package/dist/core/scene/node.js.map +0 -1
- package/dist/core/scene/nodes/artboard.d.ts +0 -42
- package/dist/core/scene/nodes/artboard.d.ts.map +0 -1
- package/dist/core/scene/nodes/artboard.js +0 -64
- package/dist/core/scene/nodes/artboard.js.map +0 -1
- package/dist/core/scene/nodes/groupnode.d.ts +0 -10
- package/dist/core/scene/nodes/groupnode.d.ts.map +0 -1
- package/dist/core/scene/nodes/groupnode.js +0 -12
- package/dist/core/scene/nodes/groupnode.js.map +0 -1
- package/dist/core/scene/nodes/imagenode.d.ts +0 -38
- package/dist/core/scene/nodes/imagenode.d.ts.map +0 -1
- package/dist/core/scene/nodes/imagenode.js +0 -77
- package/dist/core/scene/nodes/imagenode.js.map +0 -1
- package/dist/core/scene/nodes/index.d.ts +0 -5
- package/dist/core/scene/nodes/index.d.ts.map +0 -1
- package/dist/core/scene/nodes/index.js +0 -5
- package/dist/core/scene/nodes/index.js.map +0 -1
- package/dist/core/scene/nodes/shapenode.d.ts +0 -76
- package/dist/core/scene/nodes/shapenode.d.ts.map +0 -1
- package/dist/core/scene/nodes/shapenode.js +0 -212
- package/dist/core/scene/nodes/shapenode.js.map +0 -1
- package/dist/core/scene/transform.d.ts +0 -27
- package/dist/core/scene/transform.d.ts.map +0 -1
- package/dist/core/scene/transform.js +0 -52
- package/dist/core/scene/transform.js.map +0 -1
- package/dist/core/serialization/index.d.ts +0 -3
- package/dist/core/serialization/index.d.ts.map +0 -1
- package/dist/core/serialization/index.js +0 -2
- package/dist/core/serialization/index.js.map +0 -1
- package/dist/core/serialization/serializer.d.ts +0 -323
- package/dist/core/serialization/serializer.d.ts.map +0 -1
- package/dist/core/serialization/serializer.js +0 -1173
- package/dist/core/serialization/serializer.js.map +0 -1
- package/dist/core/serialization/types.d.ts +0 -242
- package/dist/core/serialization/types.d.ts.map +0 -1
- package/dist/core/serialization/types.js +0 -1
- package/dist/core/serialization/types.js.map +0 -1
- package/dist/core/timing/clock.d.ts +0 -43
- package/dist/core/timing/clock.d.ts.map +0 -1
- package/dist/core/timing/clock.js +0 -78
- package/dist/core/timing/clock.js.map +0 -1
- package/dist/core/timing/index.d.ts +0 -3
- package/dist/core/timing/index.d.ts.map +0 -1
- package/dist/core/timing/index.js +0 -3
- package/dist/core/timing/index.js.map +0 -1
- package/dist/core/timing/scheduler.d.ts +0 -72
- package/dist/core/timing/scheduler.d.ts.map +0 -1
- package/dist/core/timing/scheduler.js +0 -163
- package/dist/core/timing/scheduler.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/wrapper/react/index.d.ts +0 -5
- package/dist/wrapper/react/index.d.ts.map +0 -1
- package/dist/wrapper/react/index.js +0 -3
- package/dist/wrapper/react/index.js.map +0 -1
- package/dist/wrapper/react/samcan-player.d.ts +0 -26
- package/dist/wrapper/react/samcan-player.d.ts.map +0 -1
- package/dist/wrapper/react/samcan-player.js +0 -19
- package/dist/wrapper/react/samcan-player.js.map +0 -1
- package/dist/wrapper/react/use-samcan-player.d.ts +0 -33
- package/dist/wrapper/react/use-samcan-player.d.ts.map +0 -1
- package/dist/wrapper/react/use-samcan-player.js +0 -65
- package/dist/wrapper/react/use-samcan-player.js.map +0 -1
- package/readme.md +0 -96
package/{license → LICENSE}
RENAMED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-present aquaticcalf
|
|
2
4
|
|
|
3
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
6
|
|
package/README.md
ADDED
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
var import_node_module = require("node:module");
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
7
|
+
var __toCommonJS = (from) => {
|
|
8
|
+
var entry = __moduleCache.get(from), desc;
|
|
9
|
+
if (entry)
|
|
10
|
+
return entry;
|
|
11
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function")
|
|
13
|
+
__getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
}));
|
|
17
|
+
__moduleCache.set(from, entry);
|
|
18
|
+
return entry;
|
|
19
|
+
};
|
|
20
|
+
var __export = (target, all) => {
|
|
21
|
+
for (var name in all)
|
|
22
|
+
__defProp(target, name, {
|
|
23
|
+
get: all[name],
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
set: (newValue) => all[name] = () => newValue
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// camera/index.ts
|
|
31
|
+
var exports_camera = {};
|
|
32
|
+
__export(exports_camera, {
|
|
33
|
+
zoom_of_camera: () => zoom_of_camera,
|
|
34
|
+
zoom_camera: () => zoom_camera,
|
|
35
|
+
zoom_at_camera: () => zoom_at_camera,
|
|
36
|
+
y_of_camera: () => y_of_camera,
|
|
37
|
+
x_of_camera: () => x_of_camera,
|
|
38
|
+
world_to_screen_camera: () => world_to_screen_camera,
|
|
39
|
+
world_to_device_camera: () => world_to_device_camera,
|
|
40
|
+
width_of_camera_world: () => width_of_camera_world,
|
|
41
|
+
view_transform_camera: () => view_transform_camera,
|
|
42
|
+
smooth_damp_camera: () => smooth_damp_camera,
|
|
43
|
+
set_camera: () => set_camera,
|
|
44
|
+
screen_to_world_camera: () => screen_to_world_camera,
|
|
45
|
+
rotation_of_camera: () => rotation_of_camera,
|
|
46
|
+
rotate_camera: () => rotate_camera,
|
|
47
|
+
position_of_camera: () => position_of_camera,
|
|
48
|
+
pixel_size_of_camera: () => pixel_size_of_camera,
|
|
49
|
+
pixel_ratio_of_viewport: () => pixel_ratio_of_viewport,
|
|
50
|
+
pan_camera: () => pan_camera,
|
|
51
|
+
lerp_camera: () => lerp_camera,
|
|
52
|
+
is_identity_camera: () => is_identity_camera,
|
|
53
|
+
inverse_view_transform_camera: () => inverse_view_transform_camera,
|
|
54
|
+
height_of_camera_world: () => height_of_camera_world,
|
|
55
|
+
fit_camera_to_bounds: () => fit_camera_to_bounds,
|
|
56
|
+
equals_camera: () => equals_camera,
|
|
57
|
+
device_width_of_viewport: () => device_width_of_viewport,
|
|
58
|
+
device_to_world_camera: () => device_to_world_camera,
|
|
59
|
+
device_height_of_viewport: () => device_height_of_viewport,
|
|
60
|
+
create_camera: () => create_camera,
|
|
61
|
+
copy_camera: () => copy_camera,
|
|
62
|
+
contains_point_camera_frustum: () => contains_point_camera_frustum,
|
|
63
|
+
clone_camera: () => clone_camera,
|
|
64
|
+
clamp_camera: () => clamp_camera,
|
|
65
|
+
camera_frustum: () => camera_frustum
|
|
66
|
+
});
|
|
67
|
+
module.exports = __toCommonJS(exports_camera);
|
|
68
|
+
|
|
69
|
+
// camera/camera.ts
|
|
70
|
+
function create_camera(x = 0, y = 0, zoom = 1, rotation = 0) {
|
|
71
|
+
return [x, y, zoom, rotation];
|
|
72
|
+
}
|
|
73
|
+
function clone_camera(c) {
|
|
74
|
+
return [c[0], c[1], c[2], c[3]];
|
|
75
|
+
}
|
|
76
|
+
function copy_camera(c, out) {
|
|
77
|
+
out[0] = c[0];
|
|
78
|
+
out[1] = c[1];
|
|
79
|
+
out[2] = c[2];
|
|
80
|
+
out[3] = c[3];
|
|
81
|
+
return out;
|
|
82
|
+
}
|
|
83
|
+
function set_camera(x, y, zoom, rotation, out) {
|
|
84
|
+
out[0] = x;
|
|
85
|
+
out[1] = y;
|
|
86
|
+
out[2] = zoom;
|
|
87
|
+
out[3] = rotation;
|
|
88
|
+
return out;
|
|
89
|
+
}
|
|
90
|
+
function x_of_camera(c) {
|
|
91
|
+
return c[0];
|
|
92
|
+
}
|
|
93
|
+
function y_of_camera(c) {
|
|
94
|
+
return c[1];
|
|
95
|
+
}
|
|
96
|
+
function zoom_of_camera(c) {
|
|
97
|
+
return c[2];
|
|
98
|
+
}
|
|
99
|
+
function rotation_of_camera(c) {
|
|
100
|
+
return c[3];
|
|
101
|
+
}
|
|
102
|
+
function position_of_camera(c, out) {
|
|
103
|
+
out[0] = c[0];
|
|
104
|
+
out[1] = c[1];
|
|
105
|
+
return out;
|
|
106
|
+
}
|
|
107
|
+
function pan_camera(c, dx, dy, out) {
|
|
108
|
+
out[0] = c[0] + dx;
|
|
109
|
+
out[1] = c[1] + dy;
|
|
110
|
+
out[2] = c[2];
|
|
111
|
+
out[3] = c[3];
|
|
112
|
+
return out;
|
|
113
|
+
}
|
|
114
|
+
function zoom_camera(c, factor, out) {
|
|
115
|
+
out[0] = c[0];
|
|
116
|
+
out[1] = c[1];
|
|
117
|
+
out[2] = c[2] * factor;
|
|
118
|
+
out[3] = c[3];
|
|
119
|
+
return out;
|
|
120
|
+
}
|
|
121
|
+
function zoom_at_camera(c, factor, anchor, out) {
|
|
122
|
+
const world_dx = anchor.world_x - c[0];
|
|
123
|
+
const world_dy = anchor.world_y - c[1];
|
|
124
|
+
const new_zoom = c[2] * factor;
|
|
125
|
+
const new_world_x = anchor.world_x - world_dx / factor;
|
|
126
|
+
const new_world_y = anchor.world_y - world_dy / factor;
|
|
127
|
+
out[0] = new_world_x;
|
|
128
|
+
out[1] = new_world_y;
|
|
129
|
+
out[2] = new_zoom;
|
|
130
|
+
out[3] = c[3];
|
|
131
|
+
return out;
|
|
132
|
+
}
|
|
133
|
+
function rotate_camera(c, angle, out) {
|
|
134
|
+
out[0] = c[0];
|
|
135
|
+
out[1] = c[1];
|
|
136
|
+
out[2] = c[2];
|
|
137
|
+
out[3] = c[3] + angle;
|
|
138
|
+
return out;
|
|
139
|
+
}
|
|
140
|
+
function clamp_camera(c, limits, out) {
|
|
141
|
+
const clamped_zoom = Math.max(limits.min_zoom, Math.min(limits.max_zoom, c[2]));
|
|
142
|
+
const clamped_x = Math.max(limits.min_x, Math.min(limits.max_x, c[0]));
|
|
143
|
+
const clamped_y = Math.max(limits.min_y, Math.min(limits.max_y, c[1]));
|
|
144
|
+
out[0] = clamped_x;
|
|
145
|
+
out[1] = clamped_y;
|
|
146
|
+
out[2] = clamped_zoom;
|
|
147
|
+
out[3] = c[3];
|
|
148
|
+
return out;
|
|
149
|
+
}
|
|
150
|
+
function lerp_camera(a, b, t, out) {
|
|
151
|
+
const clamped_t = Math.max(0, Math.min(1, t));
|
|
152
|
+
out[0] = a[0] + clamped_t * (b[0] - a[0]);
|
|
153
|
+
out[1] = a[1] + clamped_t * (b[1] - a[1]);
|
|
154
|
+
out[2] = a[2] + clamped_t * (b[2] - a[2]);
|
|
155
|
+
let rotation_diff = b[3] - a[3];
|
|
156
|
+
while (rotation_diff > Math.PI) {
|
|
157
|
+
rotation_diff = rotation_diff - 2 * Math.PI;
|
|
158
|
+
}
|
|
159
|
+
while (rotation_diff < -Math.PI) {
|
|
160
|
+
rotation_diff = rotation_diff + 2 * Math.PI;
|
|
161
|
+
}
|
|
162
|
+
out[3] = a[3] + clamped_t * rotation_diff;
|
|
163
|
+
return out;
|
|
164
|
+
}
|
|
165
|
+
function smooth_damp_camera(current, target, velocity, smooth_time, delta_time, out) {
|
|
166
|
+
const omega = 2 / Math.max(0.0001, smooth_time);
|
|
167
|
+
const x = omega * delta_time;
|
|
168
|
+
const exp = 1 / (1 + x + 0.48 * x * x + 0.235 * x * x * x);
|
|
169
|
+
const delta_x = current[0] - target[0];
|
|
170
|
+
const delta_y = current[1] - target[1];
|
|
171
|
+
const delta_zoom = current[2] - target[2];
|
|
172
|
+
let rotation_diff = target[3] - current[3];
|
|
173
|
+
while (rotation_diff > Math.PI) {
|
|
174
|
+
rotation_diff = rotation_diff - 2 * Math.PI;
|
|
175
|
+
}
|
|
176
|
+
while (rotation_diff < -Math.PI) {
|
|
177
|
+
rotation_diff = rotation_diff + 2 * Math.PI;
|
|
178
|
+
}
|
|
179
|
+
const delta_rotation = -rotation_diff;
|
|
180
|
+
const temp_x = (velocity[0] + omega * delta_x) * delta_time;
|
|
181
|
+
const temp_y = (velocity[1] + omega * delta_y) * delta_time;
|
|
182
|
+
const temp_zoom = (velocity[2] + omega * delta_zoom) * delta_time;
|
|
183
|
+
const temp_rotation = (velocity[3] + omega * delta_rotation) * delta_time;
|
|
184
|
+
const new_velocity_x = (velocity[0] - omega * temp_x) * exp;
|
|
185
|
+
const new_velocity_y = (velocity[1] - omega * temp_y) * exp;
|
|
186
|
+
const new_velocity_zoom = (velocity[2] - omega * temp_zoom) * exp;
|
|
187
|
+
const new_velocity_rotation = (velocity[3] - omega * temp_rotation) * exp;
|
|
188
|
+
velocity[0] = new_velocity_x;
|
|
189
|
+
velocity[1] = new_velocity_y;
|
|
190
|
+
velocity[2] = new_velocity_zoom;
|
|
191
|
+
velocity[3] = new_velocity_rotation;
|
|
192
|
+
const result_x = target[0] + (delta_x + temp_x) * exp;
|
|
193
|
+
const result_y = target[1] + (delta_y + temp_y) * exp;
|
|
194
|
+
const result_zoom = target[2] + (delta_zoom + temp_zoom) * exp;
|
|
195
|
+
const result_rotation = target[3] + (delta_rotation + temp_rotation) * exp;
|
|
196
|
+
out[0] = result_x;
|
|
197
|
+
out[1] = result_y;
|
|
198
|
+
out[2] = result_zoom;
|
|
199
|
+
out[3] = result_rotation;
|
|
200
|
+
return out;
|
|
201
|
+
}
|
|
202
|
+
function equals_camera(c1, c2, epsilon = 0.0001) {
|
|
203
|
+
return Math.abs(c1[0] - c2[0]) < epsilon && Math.abs(c1[1] - c2[1]) < epsilon && Math.abs(c1[2] - c2[2]) < epsilon && Math.abs(c1[3] - c2[3]) < epsilon;
|
|
204
|
+
}
|
|
205
|
+
function is_identity_camera(c) {
|
|
206
|
+
return c[0] === 0 && c[1] === 0 && c[2] === 1 && c[3] === 0;
|
|
207
|
+
}
|
|
208
|
+
// camera/projection.ts
|
|
209
|
+
function world_to_screen_camera(c, v, world_pos, out) {
|
|
210
|
+
const dx = world_pos[0] - c[0];
|
|
211
|
+
const dy = world_pos[1] - c[1];
|
|
212
|
+
const cos_r = Math.cos(c[3]);
|
|
213
|
+
const sin_r = Math.sin(c[3]);
|
|
214
|
+
const rotated_x = dx * cos_r - dy * sin_r;
|
|
215
|
+
const rotated_y = dx * sin_r + dy * cos_r;
|
|
216
|
+
const screen_x = rotated_x * c[2] + v[0] / 2;
|
|
217
|
+
const screen_y = rotated_y * c[2] + v[1] / 2;
|
|
218
|
+
out[0] = screen_x;
|
|
219
|
+
out[1] = screen_y;
|
|
220
|
+
return out;
|
|
221
|
+
}
|
|
222
|
+
function screen_to_world_camera(c, v, screen_pos, out) {
|
|
223
|
+
if (c[2] <= 0) {
|
|
224
|
+
out[0] = c[0];
|
|
225
|
+
out[1] = c[1];
|
|
226
|
+
return out;
|
|
227
|
+
}
|
|
228
|
+
const dx = screen_pos[0] - v[0] / 2;
|
|
229
|
+
const dy = screen_pos[1] - v[1] / 2;
|
|
230
|
+
const cos_r = Math.cos(-c[3]);
|
|
231
|
+
const sin_r = Math.sin(-c[3]);
|
|
232
|
+
const scaled_x = dx / c[2];
|
|
233
|
+
const scaled_y = dy / c[2];
|
|
234
|
+
const rotated_x = scaled_x * cos_r - scaled_y * sin_r;
|
|
235
|
+
const rotated_y = scaled_x * sin_r + scaled_y * cos_r;
|
|
236
|
+
out[0] = rotated_x + c[0];
|
|
237
|
+
out[1] = rotated_y + c[1];
|
|
238
|
+
return out;
|
|
239
|
+
}
|
|
240
|
+
function view_transform_camera(c, out) {
|
|
241
|
+
const cos_r = Math.cos(c[3]);
|
|
242
|
+
const sin_r = Math.sin(c[3]);
|
|
243
|
+
out[0] = cos_r * c[2];
|
|
244
|
+
out[1] = sin_r * c[2];
|
|
245
|
+
out[2] = -sin_r * c[2];
|
|
246
|
+
out[3] = cos_r * c[2];
|
|
247
|
+
out[4] = -c[0] * cos_r * c[2] + c[1] * sin_r * c[2];
|
|
248
|
+
out[5] = -c[0] * sin_r * c[2] - c[1] * cos_r * c[2];
|
|
249
|
+
return out;
|
|
250
|
+
}
|
|
251
|
+
function inverse_view_transform_camera(c, out) {
|
|
252
|
+
const cos_r = Math.cos(c[3]);
|
|
253
|
+
const sin_r = Math.sin(c[3]);
|
|
254
|
+
const safe_zoom = c[2] <= 0 ? 0.0001 : c[2];
|
|
255
|
+
const inverse_zoom = 1 / safe_zoom;
|
|
256
|
+
out[0] = cos_r * inverse_zoom;
|
|
257
|
+
out[1] = -sin_r * inverse_zoom;
|
|
258
|
+
out[2] = sin_r * inverse_zoom;
|
|
259
|
+
out[3] = cos_r * inverse_zoom;
|
|
260
|
+
out[4] = c[0];
|
|
261
|
+
out[5] = c[1];
|
|
262
|
+
return out;
|
|
263
|
+
}
|
|
264
|
+
function camera_frustum(c, v, out) {
|
|
265
|
+
if (c[2] <= 0) {
|
|
266
|
+
out[0] = c[0];
|
|
267
|
+
out[1] = c[0];
|
|
268
|
+
out[2] = c[1];
|
|
269
|
+
out[3] = c[1];
|
|
270
|
+
out[4] = 0;
|
|
271
|
+
out[5] = Number.MAX_VALUE;
|
|
272
|
+
return out;
|
|
273
|
+
}
|
|
274
|
+
const half_width = v[0] / (2 * c[2]);
|
|
275
|
+
const half_height = v[1] / (2 * c[2]);
|
|
276
|
+
if (c[3] === 0) {
|
|
277
|
+
out[0] = c[0] - half_width;
|
|
278
|
+
out[1] = c[0] + half_width;
|
|
279
|
+
out[2] = c[1] + half_height;
|
|
280
|
+
out[3] = c[1] - half_height;
|
|
281
|
+
out[4] = 0;
|
|
282
|
+
out[5] = Number.MAX_VALUE;
|
|
283
|
+
return out;
|
|
284
|
+
}
|
|
285
|
+
const cos_r = Math.abs(Math.cos(c[3]));
|
|
286
|
+
const sin_r = Math.abs(Math.sin(c[3]));
|
|
287
|
+
const x_extent = half_width * cos_r + half_height * sin_r;
|
|
288
|
+
const y_extent = half_width * sin_r + half_height * cos_r;
|
|
289
|
+
out[0] = c[0] - x_extent;
|
|
290
|
+
out[1] = c[0] + x_extent;
|
|
291
|
+
out[2] = c[1] + y_extent;
|
|
292
|
+
out[3] = c[1] - y_extent;
|
|
293
|
+
out[4] = 0;
|
|
294
|
+
out[5] = Number.MAX_VALUE;
|
|
295
|
+
return out;
|
|
296
|
+
}
|
|
297
|
+
function fit_camera_to_bounds(bounds, v, margin = 0.1, out) {
|
|
298
|
+
const bounds_width = bounds[2];
|
|
299
|
+
const bounds_height = bounds[3];
|
|
300
|
+
if (bounds_width <= 0 || bounds_height <= 0) {
|
|
301
|
+
out[0] = bounds[0];
|
|
302
|
+
out[1] = bounds[1];
|
|
303
|
+
out[2] = 1;
|
|
304
|
+
out[3] = 0;
|
|
305
|
+
return out;
|
|
306
|
+
}
|
|
307
|
+
const viewport_width = v[0] * (1 - margin * 2);
|
|
308
|
+
const viewport_height = v[1] * (1 - margin * 2);
|
|
309
|
+
if (viewport_width <= 0 || viewport_height <= 0) {
|
|
310
|
+
out[0] = bounds[0] + bounds_width / 2;
|
|
311
|
+
out[1] = bounds[1] + bounds_height / 2;
|
|
312
|
+
out[2] = 1;
|
|
313
|
+
out[3] = 0;
|
|
314
|
+
return out;
|
|
315
|
+
}
|
|
316
|
+
const zoom_x = viewport_width / bounds_width;
|
|
317
|
+
const zoom_y = viewport_height / bounds_height;
|
|
318
|
+
const zoom = Math.min(zoom_x, zoom_y);
|
|
319
|
+
const center_x = bounds[0] + bounds_width / 2;
|
|
320
|
+
const center_y = bounds[1] + bounds_height / 2;
|
|
321
|
+
out[0] = center_x;
|
|
322
|
+
out[1] = center_y;
|
|
323
|
+
out[2] = zoom;
|
|
324
|
+
out[3] = 0;
|
|
325
|
+
return out;
|
|
326
|
+
}
|
|
327
|
+
function contains_point_camera_frustum(c, v, world_x, world_y) {
|
|
328
|
+
const dx = world_x - c[0];
|
|
329
|
+
const dy = world_y - c[1];
|
|
330
|
+
const cos_r = Math.cos(-c[3]);
|
|
331
|
+
const sin_r = Math.sin(-c[3]);
|
|
332
|
+
const rotated_x = dx * cos_r - dy * sin_r;
|
|
333
|
+
const rotated_y = dx * sin_r + dy * cos_r;
|
|
334
|
+
const scaled_x = rotated_x * c[2];
|
|
335
|
+
const scaled_y = rotated_y * c[2];
|
|
336
|
+
const half_width = v[0] / 2;
|
|
337
|
+
const half_height = v[1] / 2;
|
|
338
|
+
return scaled_x >= -half_width && scaled_x <= half_width && scaled_y >= -half_height && scaled_y <= half_height;
|
|
339
|
+
}
|
|
340
|
+
function width_of_camera_world(c, v) {
|
|
341
|
+
const safe_zoom = c[2] <= 0 ? 0.0001 : c[2];
|
|
342
|
+
return v[0] / safe_zoom;
|
|
343
|
+
}
|
|
344
|
+
function height_of_camera_world(c, v) {
|
|
345
|
+
const safe_zoom = c[2] <= 0 ? 0.0001 : c[2];
|
|
346
|
+
return v[1] / safe_zoom;
|
|
347
|
+
}
|
|
348
|
+
function pixel_size_of_camera(c) {
|
|
349
|
+
const safe_zoom = c[2] <= 0 ? 0.0001 : c[2];
|
|
350
|
+
return 1 / safe_zoom;
|
|
351
|
+
}
|
|
352
|
+
function pixel_ratio_of_viewport(v) {
|
|
353
|
+
return v[2];
|
|
354
|
+
}
|
|
355
|
+
function device_width_of_viewport(v) {
|
|
356
|
+
return v[0] * v[2];
|
|
357
|
+
}
|
|
358
|
+
function device_height_of_viewport(v) {
|
|
359
|
+
return v[1] * v[2];
|
|
360
|
+
}
|
|
361
|
+
function world_to_device_camera(c, v, world_pos, out) {
|
|
362
|
+
world_to_screen_camera(c, v, world_pos, out);
|
|
363
|
+
out[0] = out[0] * v[2];
|
|
364
|
+
out[1] = out[1] * v[2];
|
|
365
|
+
return out;
|
|
366
|
+
}
|
|
367
|
+
function device_to_world_camera(c, v, device_pos, out) {
|
|
368
|
+
const screen_pos = [device_pos[0] / v[2], device_pos[1] / v[2]];
|
|
369
|
+
return screen_to_world_camera(c, v, screen_pos, out);
|
|
370
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
type camera = [number, number, number, number];
|
|
2
|
+
type camera_limits = {
|
|
3
|
+
readonly min_zoom: number;
|
|
4
|
+
readonly max_zoom: number;
|
|
5
|
+
readonly min_x: number;
|
|
6
|
+
readonly max_x: number;
|
|
7
|
+
readonly min_y: number;
|
|
8
|
+
readonly max_y: number;
|
|
9
|
+
};
|
|
10
|
+
type zoom_anchor = {
|
|
11
|
+
readonly screen_x: number;
|
|
12
|
+
readonly screen_y: number;
|
|
13
|
+
readonly world_x: number;
|
|
14
|
+
readonly world_y: number;
|
|
15
|
+
};
|
|
16
|
+
declare function create_camera(x?: number, y?: number, zoom?: number, rotation?: number): camera;
|
|
17
|
+
declare function clone_camera(c: camera): camera;
|
|
18
|
+
declare function copy_camera(c: camera, out: camera): camera;
|
|
19
|
+
declare function set_camera(x: number, y: number, zoom: number, rotation: number, out: camera): camera;
|
|
20
|
+
declare function x_of_camera(c: camera): number;
|
|
21
|
+
declare function y_of_camera(c: camera): number;
|
|
22
|
+
declare function zoom_of_camera(c: camera): number;
|
|
23
|
+
declare function rotation_of_camera(c: camera): number;
|
|
24
|
+
declare function position_of_camera(c: camera, out: [number, number]): [number, number];
|
|
25
|
+
declare function pan_camera(c: camera, dx: number, dy: number, out: camera): camera;
|
|
26
|
+
declare function zoom_camera(c: camera, factor: number, out: camera): camera;
|
|
27
|
+
declare function zoom_at_camera(c: camera, factor: number, anchor: zoom_anchor, out: camera): camera;
|
|
28
|
+
declare function rotate_camera(c: camera, angle: number, out: camera): camera;
|
|
29
|
+
declare function clamp_camera(c: camera, limits: camera_limits, out: camera): camera;
|
|
30
|
+
declare function lerp_camera(a: camera, b: camera, t: number, out: camera): camera;
|
|
31
|
+
declare function smooth_damp_camera(current: camera, target: camera, velocity: camera, smooth_time: number, delta_time: number, out: camera): camera;
|
|
32
|
+
declare function equals_camera(c1: camera, c2: camera, epsilon?: number): boolean;
|
|
33
|
+
declare function is_identity_camera(c: camera): boolean;
|
|
34
|
+
type vector2 = [number, number];
|
|
35
|
+
type rectangle = [number, number, number, number];
|
|
36
|
+
type frustum = [number, number, number, number, number, number];
|
|
37
|
+
type transform = [number, number, number, number, number, number];
|
|
38
|
+
type viewport = [number, number, number];
|
|
39
|
+
declare function world_to_screen_camera(c: camera, v: viewport, world_pos: vector2, out: vector2): vector2;
|
|
40
|
+
declare function screen_to_world_camera(c: camera, v: viewport, screen_pos: vector2, out: vector2): vector2;
|
|
41
|
+
declare function view_transform_camera(c: camera, out: transform): transform;
|
|
42
|
+
declare function inverse_view_transform_camera(c: camera, out: transform): transform;
|
|
43
|
+
declare function camera_frustum(c: camera, v: viewport, out: frustum): frustum;
|
|
44
|
+
declare function fit_camera_to_bounds(bounds: rectangle, v: viewport, margin: number | undefined, out: camera): camera;
|
|
45
|
+
declare function contains_point_camera_frustum(c: camera, v: viewport, world_x: number, world_y: number): boolean;
|
|
46
|
+
declare function width_of_camera_world(c: camera, v: viewport): number;
|
|
47
|
+
declare function height_of_camera_world(c: camera, v: viewport): number;
|
|
48
|
+
declare function pixel_size_of_camera(c: camera): number;
|
|
49
|
+
declare function pixel_ratio_of_viewport(v: viewport): number;
|
|
50
|
+
declare function device_width_of_viewport(v: viewport): number;
|
|
51
|
+
declare function device_height_of_viewport(v: viewport): number;
|
|
52
|
+
declare function world_to_device_camera(c: camera, v: viewport, world_pos: vector2, out: vector2): vector2;
|
|
53
|
+
declare function device_to_world_camera(c: camera, v: viewport, device_pos: vector2, out: vector2): vector2;
|
|
54
|
+
export { zoom_of_camera, zoom_camera, zoom_at_camera, zoom_anchor, y_of_camera, x_of_camera, world_to_screen_camera, world_to_device_camera, width_of_camera_world, viewport, view_transform_camera, smooth_damp_camera, set_camera, screen_to_world_camera, rotation_of_camera, rotate_camera, position_of_camera, pixel_size_of_camera, pixel_ratio_of_viewport, pan_camera, lerp_camera, is_identity_camera, inverse_view_transform_camera, height_of_camera_world, fit_camera_to_bounds, equals_camera, device_width_of_viewport, device_to_world_camera, device_height_of_viewport, create_camera, copy_camera, contains_point_camera_frustum, clone_camera, clamp_camera, camera_limits, camera_frustum, camera };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
type camera = [number, number, number, number];
|
|
2
|
+
type camera_limits = {
|
|
3
|
+
readonly min_zoom: number;
|
|
4
|
+
readonly max_zoom: number;
|
|
5
|
+
readonly min_x: number;
|
|
6
|
+
readonly max_x: number;
|
|
7
|
+
readonly min_y: number;
|
|
8
|
+
readonly max_y: number;
|
|
9
|
+
};
|
|
10
|
+
type zoom_anchor = {
|
|
11
|
+
readonly screen_x: number;
|
|
12
|
+
readonly screen_y: number;
|
|
13
|
+
readonly world_x: number;
|
|
14
|
+
readonly world_y: number;
|
|
15
|
+
};
|
|
16
|
+
declare function create_camera(x?: number, y?: number, zoom?: number, rotation?: number): camera;
|
|
17
|
+
declare function clone_camera(c: camera): camera;
|
|
18
|
+
declare function copy_camera(c: camera, out: camera): camera;
|
|
19
|
+
declare function set_camera(x: number, y: number, zoom: number, rotation: number, out: camera): camera;
|
|
20
|
+
declare function x_of_camera(c: camera): number;
|
|
21
|
+
declare function y_of_camera(c: camera): number;
|
|
22
|
+
declare function zoom_of_camera(c: camera): number;
|
|
23
|
+
declare function rotation_of_camera(c: camera): number;
|
|
24
|
+
declare function position_of_camera(c: camera, out: [number, number]): [number, number];
|
|
25
|
+
declare function pan_camera(c: camera, dx: number, dy: number, out: camera): camera;
|
|
26
|
+
declare function zoom_camera(c: camera, factor: number, out: camera): camera;
|
|
27
|
+
declare function zoom_at_camera(c: camera, factor: number, anchor: zoom_anchor, out: camera): camera;
|
|
28
|
+
declare function rotate_camera(c: camera, angle: number, out: camera): camera;
|
|
29
|
+
declare function clamp_camera(c: camera, limits: camera_limits, out: camera): camera;
|
|
30
|
+
declare function lerp_camera(a: camera, b: camera, t: number, out: camera): camera;
|
|
31
|
+
declare function smooth_damp_camera(current: camera, target: camera, velocity: camera, smooth_time: number, delta_time: number, out: camera): camera;
|
|
32
|
+
declare function equals_camera(c1: camera, c2: camera, epsilon?: number): boolean;
|
|
33
|
+
declare function is_identity_camera(c: camera): boolean;
|
|
34
|
+
type vector2 = [number, number];
|
|
35
|
+
type rectangle = [number, number, number, number];
|
|
36
|
+
type frustum = [number, number, number, number, number, number];
|
|
37
|
+
type transform = [number, number, number, number, number, number];
|
|
38
|
+
type viewport = [number, number, number];
|
|
39
|
+
declare function world_to_screen_camera(c: camera, v: viewport, world_pos: vector2, out: vector2): vector2;
|
|
40
|
+
declare function screen_to_world_camera(c: camera, v: viewport, screen_pos: vector2, out: vector2): vector2;
|
|
41
|
+
declare function view_transform_camera(c: camera, out: transform): transform;
|
|
42
|
+
declare function inverse_view_transform_camera(c: camera, out: transform): transform;
|
|
43
|
+
declare function camera_frustum(c: camera, v: viewport, out: frustum): frustum;
|
|
44
|
+
declare function fit_camera_to_bounds(bounds: rectangle, v: viewport, margin: number | undefined, out: camera): camera;
|
|
45
|
+
declare function contains_point_camera_frustum(c: camera, v: viewport, world_x: number, world_y: number): boolean;
|
|
46
|
+
declare function width_of_camera_world(c: camera, v: viewport): number;
|
|
47
|
+
declare function height_of_camera_world(c: camera, v: viewport): number;
|
|
48
|
+
declare function pixel_size_of_camera(c: camera): number;
|
|
49
|
+
declare function pixel_ratio_of_viewport(v: viewport): number;
|
|
50
|
+
declare function device_width_of_viewport(v: viewport): number;
|
|
51
|
+
declare function device_height_of_viewport(v: viewport): number;
|
|
52
|
+
declare function world_to_device_camera(c: camera, v: viewport, world_pos: vector2, out: vector2): vector2;
|
|
53
|
+
declare function device_to_world_camera(c: camera, v: viewport, device_pos: vector2, out: vector2): vector2;
|
|
54
|
+
export { zoom_of_camera, zoom_camera, zoom_at_camera, zoom_anchor, y_of_camera, x_of_camera, world_to_screen_camera, world_to_device_camera, width_of_camera_world, viewport, view_transform_camera, smooth_damp_camera, set_camera, screen_to_world_camera, rotation_of_camera, rotate_camera, position_of_camera, pixel_size_of_camera, pixel_ratio_of_viewport, pan_camera, lerp_camera, is_identity_camera, inverse_view_transform_camera, height_of_camera_world, fit_camera_to_bounds, equals_camera, device_width_of_viewport, device_to_world_camera, device_height_of_viewport, create_camera, copy_camera, contains_point_camera_frustum, clone_camera, clamp_camera, camera_limits, camera_frustum, camera };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {
|
|
2
|
+
camera_frustum,
|
|
3
|
+
clamp_camera,
|
|
4
|
+
clone_camera,
|
|
5
|
+
contains_point_camera_frustum,
|
|
6
|
+
copy_camera,
|
|
7
|
+
create_camera,
|
|
8
|
+
device_height_of_viewport,
|
|
9
|
+
device_to_world_camera,
|
|
10
|
+
device_width_of_viewport,
|
|
11
|
+
equals_camera,
|
|
12
|
+
fit_camera_to_bounds,
|
|
13
|
+
height_of_camera_world,
|
|
14
|
+
inverse_view_transform_camera,
|
|
15
|
+
is_identity_camera,
|
|
16
|
+
lerp_camera,
|
|
17
|
+
pan_camera,
|
|
18
|
+
pixel_ratio_of_viewport,
|
|
19
|
+
pixel_size_of_camera,
|
|
20
|
+
position_of_camera,
|
|
21
|
+
rotate_camera,
|
|
22
|
+
rotation_of_camera,
|
|
23
|
+
screen_to_world_camera,
|
|
24
|
+
set_camera,
|
|
25
|
+
smooth_damp_camera,
|
|
26
|
+
view_transform_camera,
|
|
27
|
+
width_of_camera_world,
|
|
28
|
+
world_to_device_camera,
|
|
29
|
+
world_to_screen_camera,
|
|
30
|
+
x_of_camera,
|
|
31
|
+
y_of_camera,
|
|
32
|
+
zoom_at_camera,
|
|
33
|
+
zoom_camera,
|
|
34
|
+
zoom_of_camera
|
|
35
|
+
} from "../shared/chunk-hewznwbd.js";
|
|
36
|
+
export {
|
|
37
|
+
zoom_of_camera,
|
|
38
|
+
zoom_camera,
|
|
39
|
+
zoom_at_camera,
|
|
40
|
+
y_of_camera,
|
|
41
|
+
x_of_camera,
|
|
42
|
+
world_to_screen_camera,
|
|
43
|
+
world_to_device_camera,
|
|
44
|
+
width_of_camera_world,
|
|
45
|
+
view_transform_camera,
|
|
46
|
+
smooth_damp_camera,
|
|
47
|
+
set_camera,
|
|
48
|
+
screen_to_world_camera,
|
|
49
|
+
rotation_of_camera,
|
|
50
|
+
rotate_camera,
|
|
51
|
+
position_of_camera,
|
|
52
|
+
pixel_size_of_camera,
|
|
53
|
+
pixel_ratio_of_viewport,
|
|
54
|
+
pan_camera,
|
|
55
|
+
lerp_camera,
|
|
56
|
+
is_identity_camera,
|
|
57
|
+
inverse_view_transform_camera,
|
|
58
|
+
height_of_camera_world,
|
|
59
|
+
fit_camera_to_bounds,
|
|
60
|
+
equals_camera,
|
|
61
|
+
device_width_of_viewport,
|
|
62
|
+
device_to_world_camera,
|
|
63
|
+
device_height_of_viewport,
|
|
64
|
+
create_camera,
|
|
65
|
+
copy_camera,
|
|
66
|
+
contains_point_camera_frustum,
|
|
67
|
+
clone_camera,
|
|
68
|
+
clamp_camera,
|
|
69
|
+
camera_frustum
|
|
70
|
+
};
|