@swf2es/player-hosts 0.0.0-stage → 0.1.1
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 +202 -0
- package/LICENSE.third-party +759 -0
- package/README.md +43 -2
- package/dist/indexeddb.d.ts +27 -0
- package/dist/indexeddb.d.ts.map +1 -0
- package/dist/indexeddb.js +170 -0
- package/dist/indexeddb.js.map +1 -0
- package/dist/node-worker.d.ts +2 -0
- package/dist/node-worker.d.ts.map +1 -0
- package/dist/node-worker.js +12 -0
- package/dist/node-worker.js.map +1 -0
- package/dist/node.d.ts +8 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +43 -0
- package/dist/node.js.map +1 -0
- package/dist/precompiled.d.ts +31 -0
- package/dist/precompiled.d.ts.map +1 -0
- package/dist/precompiled.js +125 -0
- package/dist/precompiled.js.map +1 -0
- package/dist/stage3d.d.ts +13 -0
- package/dist/stage3d.d.ts.map +1 -0
- package/dist/stage3d.js +61 -0
- package/dist/stage3d.js.map +1 -0
- package/dist/thread/codegen/codegen.js +308 -0
- package/dist/thread/codegen/index.js +405 -0
- package/dist/thread/format/abc-names.js +126 -0
- package/dist/thread/format/actions.js +222 -0
- package/dist/thread/format/air-descriptor.js +63 -0
- package/dist/thread/format/api-versions.js +22 -0
- package/dist/thread/format/bitmap.js +199 -0
- package/dist/thread/format/button.js +60 -0
- package/dist/thread/format/compression.js +200 -0
- package/dist/thread/format/display.js +305 -0
- package/dist/thread/format/filters.js +136 -0
- package/dist/thread/format/font.js +168 -0
- package/dist/thread/format/index.js +26 -0
- package/dist/thread/format/pbj.js +484 -0
- package/dist/thread/format/shape.js +411 -0
- package/dist/thread/format/sound.js +91 -0
- package/dist/thread/format/swf.js +163 -0
- package/dist/thread/format/tags.js +58 -0
- package/dist/thread/format/text.js +135 -0
- package/dist/thread/format/zip.js +91 -0
- package/dist/thread/native/audio/binary.js +3 -0
- package/dist/thread/native/audio/index.js +72 -0
- package/dist/thread/native/base64.js +9 -0
- package/dist/thread/native/compress/binary.js +3 -0
- package/dist/thread/native/compress/index.js +145 -0
- package/dist/thread/native/instance.js +49 -0
- package/dist/thread/native/mp3/binary.js +3 -0
- package/dist/thread/native/mp3/index.js +48 -0
- package/dist/thread/native/render/binary.js +3 -0
- package/dist/thread/native/render/bitmap-kernel.js +591 -0
- package/dist/thread/native/render/draw-kernel.js +204 -0
- package/dist/thread/native/render/dxt-encoder.js +94 -0
- package/dist/thread/native/render/index.js +10 -0
- package/dist/thread/native/render/lines.js +122 -0
- package/dist/thread/native/render/module.js +26 -0
- package/dist/thread/native/render/pixel-ops.js +235 -0
- package/dist/thread/native/render/tessellator.js +250 -0
- package/dist/thread/player/avm1/amf.js +507 -0
- package/dist/thread/player/avm1/avm1.js +1304 -0
- package/dist/thread/player/avm1/bindings.js +214 -0
- package/dist/thread/player/avm1/classes.js +75 -0
- package/dist/thread/player/avm1/clips.js +229 -0
- package/dist/thread/player/avm1/compile.js +140 -0
- package/dist/thread/player/avm1/external.js +79 -0
- package/dist/thread/player/avm1/focus.js +278 -0
- package/dist/thread/player/avm1/globals/BitmapData.js +542 -0
- package/dist/thread/player/avm1/globals/Button.js +31 -0
- package/dist/thread/player/avm1/globals/Color.js +115 -0
- package/dist/thread/player/avm1/globals/ExternalInterface.js +310 -0
- package/dist/thread/player/avm1/globals/FileReference.js +217 -0
- package/dist/thread/player/avm1/globals/Key.js +60 -0
- package/dist/thread/player/avm1/globals/LoadVars.js +208 -0
- package/dist/thread/player/avm1/globals/LocalConnection.js +92 -0
- package/dist/thread/player/avm1/globals/MovieClip.js +1070 -0
- package/dist/thread/player/avm1/globals/MovieClipLoader.js +90 -0
- package/dist/thread/player/avm1/globals/NetConnection.js +261 -0
- package/dist/thread/player/avm1/globals/PrintJob.js +37 -0
- package/dist/thread/player/avm1/globals/Selection.js +62 -0
- package/dist/thread/player/avm1/globals/SharedObject.js +245 -0
- package/dist/thread/player/avm1/globals/Sound.js +238 -0
- package/dist/thread/player/avm1/globals/Stage.js +12 -0
- package/dist/thread/player/avm1/globals/StyleSheet.js +205 -0
- package/dist/thread/player/avm1/globals/TextField.js +396 -0
- package/dist/thread/player/avm1/globals/TextFormat.js +194 -0
- package/dist/thread/player/avm1/globals/TextSnapshot.js +88 -0
- package/dist/thread/player/avm1/globals/XML.js +396 -0
- package/dist/thread/player/avm1/globals/XMLNode.js +413 -0
- package/dist/thread/player/avm1/globals/XMLSocket.js +205 -0
- package/dist/thread/player/avm1/globals/drawing.js +202 -0
- package/dist/thread/player/avm1/globals/filters.js +635 -0
- package/dist/thread/player/avm1/globals/geom.js +600 -0
- package/dist/thread/player/avm1/input.js +483 -0
- package/dist/thread/player/avm1/keyboard.js +113 -0
- package/dist/thread/player/avm1/loads.js +352 -0
- package/dist/thread/player/avm1/net.js +219 -0
- package/dist/thread/player/avm1/paths.js +104 -0
- package/dist/thread/player/avm1/pointer.js +512 -0
- package/dist/thread/player/avm1/queue.js +303 -0
- package/dist/thread/player/avm1/sound.js +106 -0
- package/dist/thread/player/avm1/swf.js +141 -0
- package/dist/thread/player/avm1/timers.js +113 -0
- package/dist/thread/player/bitmap/bitmap.js +627 -0
- package/dist/thread/player/bitmap/draw.js +68 -0
- package/dist/thread/player/bitmap/dxt.js +11 -0
- package/dist/thread/player/bitmap/filters.js +656 -0
- package/dist/thread/player/bitmap/images.js +240 -0
- package/dist/thread/player/bitmap/kernel.js +65 -0
- package/dist/thread/player/bitmap/ops.js +1239 -0
- package/dist/thread/player/bitmap/pixel-bender.js +911 -0
- package/dist/thread/player/bitmap/png.js +139 -0
- package/dist/thread/player/bitmap/turbulence.js +89 -0
- package/dist/thread/player/clock.js +182 -0
- package/dist/thread/player/display/bitmapobject.js +25 -0
- package/dist/thread/player/display/bounds.js +520 -0
- package/dist/thread/player/display/buttonobject.js +305 -0
- package/dist/thread/player/display/color.js +40 -0
- package/dist/thread/player/display/container.js +150 -0
- package/dist/thread/player/display/display.js +14 -0
- package/dist/thread/player/display/displayobject.js +664 -0
- package/dist/thread/player/display/drawing.js +613 -0
- package/dist/thread/player/display/filters.js +285 -0
- package/dist/thread/player/display/geometry.js +189 -0
- package/dist/thread/player/display/gradients.js +117 -0
- package/dist/thread/player/display/graphicsdata.js +592 -0
- package/dist/thread/player/display/instantiate.js +71 -0
- package/dist/thread/player/display/matrix3d.js +373 -0
- package/dist/thread/player/display/morph.js +226 -0
- package/dist/thread/player/display/movieclip.js +680 -0
- package/dist/thread/player/display/perspective.js +193 -0
- package/dist/thread/player/display/scale9.js +236 -0
- package/dist/thread/player/display/shapeobject.js +131 -0
- package/dist/thread/player/display/shapes.js +407 -0
- package/dist/thread/player/display/textobjects.js +222 -0
- package/dist/thread/player/display/timeline.js +471 -0
- package/dist/thread/player/display/value-lists.js +40 -0
- package/dist/thread/player/display/videoobject.js +6 -0
- package/dist/thread/player/display/walk.js +127 -0
- package/dist/thread/player/files.js +334 -0
- package/dist/thread/player/hosts.js +207 -0
- package/dist/thread/player/input/avm1.js +82 -0
- package/dist/thread/player/input/context-menu.js +63 -0
- package/dist/thread/player/input/keyboard.js +458 -0
- package/dist/thread/player/input/pointer.js +863 -0
- package/dist/thread/player/input/text-editor.js +319 -0
- package/dist/thread/player/input/touch.js +209 -0
- package/dist/thread/player/localconnection.js +90 -0
- package/dist/thread/player/media/audio.js +376 -0
- package/dist/thread/player/media/dynamic-sound.js +90 -0
- package/dist/thread/player/media/extract.js +135 -0
- package/dist/thread/player/media/mp3.js +152 -0
- package/dist/thread/player/media/sounds.js +507 -0
- package/dist/thread/player/media/streaming-audio.js +133 -0
- package/dist/thread/player/player.js +616 -0
- package/dist/thread/player/playerglobal/air/net/WebSocket.js +250 -0
- package/dist/thread/player/playerglobal/air-library.js +8 -0
- package/dist/thread/player/playerglobal/flash/accessibility/Accessibility.js +21 -0
- package/dist/thread/player/playerglobal/flash/crypto/generateRandomBytes.js +32 -0
- package/dist/thread/player/playerglobal/flash/data/EncryptedLocalStore.js +61 -0
- package/dist/thread/player/playerglobal/flash/desktop/Clipboard.js +173 -0
- package/dist/thread/player/playerglobal/flash/desktop/NativeApplication.js +179 -0
- package/dist/thread/player/playerglobal/flash/display/AVM1Movie.js +19 -0
- package/dist/thread/player/playerglobal/flash/display/Bitmap.js +58 -0
- package/dist/thread/player/playerglobal/flash/display/BitmapData.js +633 -0
- package/dist/thread/player/playerglobal/flash/display/DisplayObject.js +614 -0
- package/dist/thread/player/playerglobal/flash/display/DisplayObjectContainer.js +224 -0
- package/dist/thread/player/playerglobal/flash/display/Graphics.js +345 -0
- package/dist/thread/player/playerglobal/flash/display/InteractiveObject.js +87 -0
- package/dist/thread/player/playerglobal/flash/display/Loader.js +79 -0
- package/dist/thread/player/playerglobal/flash/display/LoaderInfo.js +128 -0
- package/dist/thread/player/playerglobal/flash/display/MovieClip.js +194 -0
- package/dist/thread/player/playerglobal/flash/display/NativeWindow.js +245 -0
- package/dist/thread/player/playerglobal/flash/display/Shader.js +26 -0
- package/dist/thread/player/playerglobal/flash/display/ShaderData.js +85 -0
- package/dist/thread/player/playerglobal/flash/display/ShaderInput.js +64 -0
- package/dist/thread/player/playerglobal/flash/display/ShaderJob.js +181 -0
- package/dist/thread/player/playerglobal/flash/display/ShaderParameter.js +23 -0
- package/dist/thread/player/playerglobal/flash/display/Shape.js +13 -0
- package/dist/thread/player/playerglobal/flash/display/SimpleButton.js +103 -0
- package/dist/thread/player/playerglobal/flash/display/Sprite.js +84 -0
- package/dist/thread/player/playerglobal/flash/display/Stage.js +231 -0
- package/dist/thread/player/playerglobal/flash/display/Stage3D.js +54 -0
- package/dist/thread/player/playerglobal/flash/display/shaders.js +228 -0
- package/dist/thread/player/playerglobal/flash/events/Event.js +58 -0
- package/dist/thread/player/playerglobal/flash/events/EventDispatcher.js +103 -0
- package/dist/thread/player/playerglobal/flash/events/GestureEvent.js +34 -0
- package/dist/thread/player/playerglobal/flash/events/HTTPStatusEvent.js +8 -0
- package/dist/thread/player/playerglobal/flash/events/KeyboardEvent.js +51 -0
- package/dist/thread/player/playerglobal/flash/events/MouseEvent.js +59 -0
- package/dist/thread/player/playerglobal/flash/events/PressAndTapGestureEvent.js +30 -0
- package/dist/thread/player/playerglobal/flash/events/TimerEvent.js +16 -0
- package/dist/thread/player/playerglobal/flash/events/TouchEvent.js +45 -0
- package/dist/thread/player/playerglobal/flash/external/ExternalInterface.js +73 -0
- package/dist/thread/player/playerglobal/flash/filesystem/File.js +340 -0
- package/dist/thread/player/playerglobal/flash/filesystem/FileStream.js +453 -0
- package/dist/thread/player/playerglobal/flash/filesystem/paths.js +156 -0
- package/dist/thread/player/playerglobal/flash/filesystem/writes.js +143 -0
- package/dist/thread/player/playerglobal/flash/filters/BevelFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/BitmapFilter.js +205 -0
- package/dist/thread/player/playerglobal/flash/filters/BlurFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/ColorMatrixFilter.js +11 -0
- package/dist/thread/player/playerglobal/flash/filters/ConvolutionFilter.js +26 -0
- package/dist/thread/player/playerglobal/flash/filters/DisplacementMapFilter.js +51 -0
- package/dist/thread/player/playerglobal/flash/filters/DropShadowFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/GlowFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/GradientBevelFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/GradientGlowFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/ShaderFilter.js +53 -0
- package/dist/thread/player/playerglobal/flash/geom/Matrix3D.js +361 -0
- package/dist/thread/player/playerglobal/flash/geom/PerspectiveProjection.js +122 -0
- package/dist/thread/player/playerglobal/flash/geom/Transform.js +245 -0
- package/dist/thread/player/playerglobal/flash/geom/Utils3D.js +85 -0
- package/dist/thread/player/playerglobal/flash/globalization/Collator.js +149 -0
- package/dist/thread/player/playerglobal/flash/globalization/CurrencyFormatter.js +272 -0
- package/dist/thread/player/playerglobal/flash/globalization/CurrencyParseResult.js +21 -0
- package/dist/thread/player/playerglobal/flash/globalization/DateTimeFormatter.js +463 -0
- package/dist/thread/player/playerglobal/flash/globalization/LocaleID.js +144 -0
- package/dist/thread/player/playerglobal/flash/globalization/NumberFormatter.js +444 -0
- package/dist/thread/player/playerglobal/flash/globalization/NumberParseResult.js +22 -0
- package/dist/thread/player/playerglobal/flash/globalization/StringTools.js +59 -0
- package/dist/thread/player/playerglobal/flash/globalization/locale.js +190 -0
- package/dist/thread/player/playerglobal/flash/media/Camera.js +89 -0
- package/dist/thread/player/playerglobal/flash/media/Microphone.js +126 -0
- package/dist/thread/player/playerglobal/flash/media/Sound.js +543 -0
- package/dist/thread/player/playerglobal/flash/media/SoundMixer.js +74 -0
- package/dist/thread/player/playerglobal/flash/media/SoundTransform.js +40 -0
- package/dist/thread/player/playerglobal/flash/media/Video.js +43 -0
- package/dist/thread/player/playerglobal/flash/net/FileFilter.js +27 -0
- package/dist/thread/player/playerglobal/flash/net/FileReference.js +197 -0
- package/dist/thread/player/playerglobal/flash/net/LocalConnection.js +167 -0
- package/dist/thread/player/playerglobal/flash/net/NetConnection.js +155 -0
- package/dist/thread/player/playerglobal/flash/net/SharedObject.js +299 -0
- package/dist/thread/player/playerglobal/flash/net/Socket.js +282 -0
- package/dist/thread/player/playerglobal/flash/net/URLRequest.js +93 -0
- package/dist/thread/player/playerglobal/flash/net/URLStream.js +146 -0
- package/dist/thread/player/playerglobal/flash/net/XMLSocket.js +14 -0
- package/dist/thread/player/playerglobal/flash/net/local-modern.js +142 -0
- package/dist/thread/player/playerglobal/flash/net/local-values.js +217 -0
- package/dist/thread/player/playerglobal/flash/net/navigateToURL.js +29 -0
- package/dist/thread/player/playerglobal/flash/profiler/Telemetry.js +25 -0
- package/dist/thread/player/playerglobal/flash/sensors/Accelerometer.js +12 -0
- package/dist/thread/player/playerglobal/flash/system/ApplicationDomain.js +69 -0
- package/dist/thread/player/playerglobal/flash/system/Capabilities.js +163 -0
- package/dist/thread/player/playerglobal/flash/system/FSCommandHost.js +17 -0
- package/dist/thread/player/playerglobal/flash/system/Security.js +46 -0
- package/dist/thread/player/playerglobal/flash/system/SecurityDomain.js +21 -0
- package/dist/thread/player/playerglobal/flash/system/System.js +73 -0
- package/dist/thread/player/playerglobal/flash/system/Worker.js +112 -0
- package/dist/thread/player/playerglobal/flash/text/Font.js +95 -0
- package/dist/thread/player/playerglobal/flash/text/StaticText.js +16 -0
- package/dist/thread/player/playerglobal/flash/text/StyleSheet.js +65 -0
- package/dist/thread/player/playerglobal/flash/text/TextField.js +707 -0
- package/dist/thread/player/playerglobal/flash/text/TextRenderer.js +77 -0
- package/dist/thread/player/playerglobal/flash/text/engine/FontDescription.js +141 -0
- package/dist/thread/player/playerglobal/flash/text/engine/TabStop.js +46 -0
- package/dist/thread/player/playerglobal/flash/trace/Trace.js +17 -0
- package/dist/thread/player/playerglobal/flash/ui/ContextMenu.js +17 -0
- package/dist/thread/player/playerglobal/flash/ui/GameInput.js +19 -0
- package/dist/thread/player/playerglobal/flash/ui/Keyboard.js +27 -0
- package/dist/thread/player/playerglobal/flash/ui/Mouse.js +127 -0
- package/dist/thread/player/playerglobal/flash/ui/Multitouch.js +46 -0
- package/dist/thread/player/playerglobal/flash/utils/ByteArray.js +155 -0
- package/dist/thread/player/playerglobal/flash/utils/Timer.js +25 -0
- package/dist/thread/player/playerglobal/flash/xml/XMLDocument.js +74 -0
- package/dist/thread/player/playerglobal/index.js +224 -0
- package/dist/thread/player/playerglobal/libraries.js +10 -0
- package/dist/thread/player/playerglobal/playerglobal-library.js +22 -0
- package/dist/thread/player/playerglobal/toplevel.js +122 -0
- package/dist/thread/player/scripting/clipboard.js +146 -0
- package/dist/thread/player/scripting/code.js +900 -0
- package/dist/thread/player/scripting/evaluate.js +144 -0
- package/dist/thread/player/scripting/events.js +172 -0
- package/dist/thread/player/scripting/handover.js +182 -0
- package/dist/thread/player/scripting/lazy.js +38 -0
- package/dist/thread/player/scripting/lifecycle.js +272 -0
- package/dist/thread/player/scripting/loads.js +860 -0
- package/dist/thread/player/scripting/sha256.js +95 -0
- package/dist/thread/player/scripting/symbols.js +348 -0
- package/dist/thread/player/scripting/timers.js +434 -0
- package/dist/thread/player/scripting/workers.js +923 -0
- package/dist/thread/player/scripting.js +1018 -0
- package/dist/thread/player/stage.js +4 -0
- package/dist/thread/player/text/csm.js +113 -0
- package/dist/thread/player/text/css.js +167 -0
- package/dist/thread/player/text/fonts.js +97 -0
- package/dist/thread/player/text/layout.js +393 -0
- package/dist/thread/player/text/static.js +109 -0
- package/dist/thread/player/text/text.js +431 -0
- package/dist/thread/player/workers/thread.js +159 -0
- package/dist/thread/player/workers/wire.js +198 -0
- package/dist/thread/player-hosts/web-worker.js +19 -0
- package/dist/thread/runtime/avm1/activation.js +89 -0
- package/dist/thread/runtime/avm1/case.js +249 -0
- package/dist/thread/runtime/avm1/clips.js +334 -0
- package/dist/thread/runtime/avm1/control.js +280 -0
- package/dist/thread/runtime/avm1/errors.js +50 -0
- package/dist/thread/runtime/avm1/functions.js +249 -0
- package/dist/thread/runtime/avm1/globals/array.js +549 -0
- package/dist/thread/runtime/avm1/globals/broadcaster.js +131 -0
- package/dist/thread/runtime/avm1/globals/date.js +436 -0
- package/dist/thread/runtime/avm1/globals/global.js +344 -0
- package/dist/thread/runtime/avm1/globals/math.js +139 -0
- package/dist/thread/runtime/avm1/globals/number.js +93 -0
- package/dist/thread/runtime/avm1/globals/string.js +201 -0
- package/dist/thread/runtime/avm1/globals/timers.js +129 -0
- package/dist/thread/runtime/avm1/host.js +5 -0
- package/dist/thread/runtime/avm1/index.js +14 -0
- package/dist/thread/runtime/avm1/inheritance.js +132 -0
- package/dist/thread/runtime/avm1/numbers.js +298 -0
- package/dist/thread/runtime/avm1/objects.js +896 -0
- package/dist/thread/runtime/avm1/operators.js +170 -0
- package/dist/thread/runtime/avm1/realm.js +529 -0
- package/dist/thread/runtime/avm1/runtime.js +882 -0
- package/dist/thread/runtime/avm1/scope.js +385 -0
- package/dist/thread/runtime/avm1/urls.js +180 -0
- package/dist/thread/runtime/avm1/values.js +97 -0
- package/dist/thread/runtime/avm2/amf-classes.js +66 -0
- package/dist/thread/runtime/avm2/amf.js +801 -0
- package/dist/thread/runtime/avm2/array-conversion.js +100 -0
- package/dist/thread/runtime/avm2/builtin-library.js +21 -0
- package/dist/thread/runtime/avm2/cache-fill.js +86 -0
- package/dist/thread/runtime/avm2/classes.js +211 -0
- package/dist/thread/runtime/avm2/definitions.js +69 -0
- package/dist/thread/runtime/avm2/descriptors.js +5 -0
- package/dist/thread/runtime/avm2/dictionary-keys.js +295 -0
- package/dist/thread/runtime/avm2/domain-memory.js +75 -0
- package/dist/thread/runtime/avm2/domain.js +280 -0
- package/dist/thread/runtime/avm2/dynamic-properties.js +182 -0
- package/dist/thread/runtime/avm2/enumeration.js +393 -0
- package/dist/thread/runtime/avm2/errors.js +45 -0
- package/dist/thread/runtime/avm2/float-library.js +66 -0
- package/dist/thread/runtime/avm2/float.js +26 -0
- package/dist/thread/runtime/avm2/hooks.js +19 -0
- package/dist/thread/runtime/avm2/index.js +38 -0
- package/dist/thread/runtime/avm2/messages.js +177 -0
- package/dist/thread/runtime/avm2/method-factories.js +95 -0
- package/dist/thread/runtime/avm2/modules.js +105 -0
- package/dist/thread/runtime/avm2/names.js +248 -0
- package/dist/thread/runtime/avm2/natives/aliases.js +47 -0
- package/dist/thread/runtime/avm2/natives/array.js +390 -0
- package/dist/thread/runtime/avm2/natives/bytearray.js +1227 -0
- package/dist/thread/runtime/avm2/natives/case.js +88 -0
- package/dist/thread/runtime/avm2/natives/concurrent.js +199 -0
- package/dist/thread/runtime/avm2/natives/date.js +581 -0
- package/dist/thread/runtime/avm2/natives/define.js +130 -0
- package/dist/thread/runtime/avm2/natives/describe.js +351 -0
- package/dist/thread/runtime/avm2/natives/dictionary.js +12 -0
- package/dist/thread/runtime/avm2/natives/float-vector.js +81 -0
- package/dist/thread/runtime/avm2/natives/float.js +96 -0
- package/dist/thread/runtime/avm2/natives/index.js +64 -0
- package/dist/thread/runtime/avm2/natives/json.js +514 -0
- package/dist/thread/runtime/avm2/natives/number.js +162 -0
- package/dist/thread/runtime/avm2/natives/object.js +237 -0
- package/dist/thread/runtime/avm2/natives/proxy.js +75 -0
- package/dist/thread/runtime/avm2/natives/regexp.js +485 -0
- package/dist/thread/runtime/avm2/natives/shell-workers.js +404 -0
- package/dist/thread/runtime/avm2/natives/shell.js +557 -0
- package/dist/thread/runtime/avm2/natives/sort.js +377 -0
- package/dist/thread/runtime/avm2/natives/string.js +132 -0
- package/dist/thread/runtime/avm2/natives/sync.js +821 -0
- package/dist/thread/runtime/avm2/natives/toplevel.js +139 -0
- package/dist/thread/runtime/avm2/natives/vector-elements.js +46 -0
- package/dist/thread/runtime/avm2/natives/vector.js +406 -0
- package/dist/thread/runtime/avm2/natives/xml/access.js +633 -0
- package/dist/thread/runtime/avm2/natives/xml/build.js +291 -0
- package/dist/thread/runtime/avm2/natives/xml/chars.js +112 -0
- package/dist/thread/runtime/avm2/natives/xml/escape.js +38 -0
- package/dist/thread/runtime/avm2/natives/xml/names.js +204 -0
- package/dist/thread/runtime/avm2/natives/xml/node.js +272 -0
- package/dist/thread/runtime/avm2/natives/xml/operators.js +69 -0
- package/dist/thread/runtime/avm2/natives/xml/parser.js +356 -0
- package/dist/thread/runtime/avm2/natives/xml/strings.js +191 -0
- package/dist/thread/runtime/avm2/natives/xml/values.js +122 -0
- package/dist/thread/runtime/avm2/natives/xml/xml.js +645 -0
- package/dist/thread/runtime/avm2/number-strings.js +110 -0
- package/dist/thread/runtime/avm2/numbers.js +558 -0
- package/dist/thread/runtime/avm2/options.js +16 -0
- package/dist/thread/runtime/avm2/player-messages.js +550 -0
- package/dist/thread/runtime/avm2/property-cache.js +135 -0
- package/dist/thread/runtime/avm2/runtime.js +2644 -0
- package/dist/thread/runtime/avm2/traits.js +509 -0
- package/dist/thread/runtime/index.js +7 -0
- package/dist/web-worker.d.ts +2 -0
- package/dist/web-worker.d.ts.map +1 -0
- package/dist/web-worker.js +20 -0
- package/dist/web-worker.js.map +1 -0
- package/dist/websocket.d.ts +4 -0
- package/dist/websocket.d.ts.map +1 -0
- package/dist/websocket.js +27 -0
- package/dist/websocket.js.map +1 -0
- package/dist/workers.d.ts +35 -0
- package/dist/workers.d.ts.map +1 -0
- package/dist/workers.js +171 -0
- package/dist/workers.js.map +1 -0
- package/package.json +62 -3
- package/src/indexeddb.ts +227 -0
- package/src/node-worker.ts +13 -0
- package/src/node.ts +49 -0
- package/src/precompiled.ts +166 -0
- package/src/stage3d.ts +76 -0
- package/src/web-worker.ts +24 -0
- package/src/websocket.ts +32 -0
- package/src/workers.ts +255 -0
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
// flash.geom.Matrix3D's 16 float32 values, in column-major rawData order,
|
|
2
|
+
// and its arithmetic, display/matrix3d.ts's float32 as Flash's.
|
|
3
|
+
import { avm2 } from "../../../../runtime/index.js";
|
|
4
|
+
import { compose3D, decompose3D, determinant3D, interpolate3D, invert3D, multiply3D, pointAt3D, rotation3D, scale3D, transform3D, translation3D, } from "../../../display/matrix3d.js";
|
|
5
|
+
/** The first index copyRawDataTo refuses: 2^28. */
|
|
6
|
+
const MAX_INDEX = 0x10000000;
|
|
7
|
+
function identity() {
|
|
8
|
+
return Float32Array.of(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
|
|
9
|
+
}
|
|
10
|
+
/** Matrix3D's values; its native constructor assigns them. */
|
|
11
|
+
function data(o) {
|
|
12
|
+
return o.$matrix3D;
|
|
13
|
+
}
|
|
14
|
+
const ORIENTATIONS = ["eulerAngles", "axisAngle", "quaternion"];
|
|
15
|
+
/**
|
|
16
|
+
* The members that change a Matrix3D in place and tell a display object that holds it. Flash's
|
|
17
|
+
* copyToMatrix3D, copyRowFrom and copyColumnFrom change it without telling it: the object stays
|
|
18
|
+
* where it was (Space.shown), its properties as they were (`three-d-matrix`).
|
|
19
|
+
*/
|
|
20
|
+
const CHANGES = [
|
|
21
|
+
"rawData",
|
|
22
|
+
"copyFrom",
|
|
23
|
+
"copyRawDataFrom",
|
|
24
|
+
"identity",
|
|
25
|
+
"transpose",
|
|
26
|
+
"appendTranslation",
|
|
27
|
+
"prependTranslation",
|
|
28
|
+
"appendScale",
|
|
29
|
+
"prependScale",
|
|
30
|
+
"appendRotation",
|
|
31
|
+
"prependRotation",
|
|
32
|
+
"append",
|
|
33
|
+
"prepend",
|
|
34
|
+
"invert",
|
|
35
|
+
"position",
|
|
36
|
+
"pointAt",
|
|
37
|
+
"recompose",
|
|
38
|
+
"interpolateTo",
|
|
39
|
+
];
|
|
40
|
+
export function matrix3DNatives(s) {
|
|
41
|
+
const natives = {};
|
|
42
|
+
let numberVector = null;
|
|
43
|
+
const axes = ["x", "y", "z", "w"];
|
|
44
|
+
const checkedAxis = (value, axis) => {
|
|
45
|
+
if (value === null || value === undefined) {
|
|
46
|
+
throw s.rt.error("TypeError", 2007, "vector3D");
|
|
47
|
+
}
|
|
48
|
+
const n = s.rt.toUint(axis);
|
|
49
|
+
if (n > 3) {
|
|
50
|
+
throw s.rt.error("ArgumentError", 2004);
|
|
51
|
+
}
|
|
52
|
+
return n;
|
|
53
|
+
};
|
|
54
|
+
const vector = (values) => {
|
|
55
|
+
numberVector ??= s.rt.resolve(s.rt.vector("Number"));
|
|
56
|
+
const o = numberVector.$it.instance();
|
|
57
|
+
o.$a = Array.from(values);
|
|
58
|
+
return o;
|
|
59
|
+
};
|
|
60
|
+
const nonNull = (v, name) => {
|
|
61
|
+
if (v === null || v === undefined) {
|
|
62
|
+
throw s.rt.error("TypeError", 2007, name);
|
|
63
|
+
}
|
|
64
|
+
return v;
|
|
65
|
+
};
|
|
66
|
+
const vector3D = (x, y, z, w) => s.rt.construct(s.rt.classNamed("flash.geom::Vector3D"), x, y, z, w);
|
|
67
|
+
const read3D = (v) => axes.map((axis) => s.rt.toNumber(s.rt.getProperty(v, s.rt.publicName(axis))));
|
|
68
|
+
const xyz = (v) => {
|
|
69
|
+
const [x, y, z] = read3D(v);
|
|
70
|
+
return [x, y, z];
|
|
71
|
+
};
|
|
72
|
+
const matrix3D = (raw) => {
|
|
73
|
+
const o = s.rt.construct(s.rt.classNamed("flash.geom::Matrix3D"));
|
|
74
|
+
data(o).set(raw);
|
|
75
|
+
return o;
|
|
76
|
+
};
|
|
77
|
+
const orientation = (style) => {
|
|
78
|
+
const name = s.rt.toString(nonNull(style, "orientationStyle"));
|
|
79
|
+
if (!ORIENTATIONS.includes(name)) {
|
|
80
|
+
throw s.rt.error("Error", 2187, name);
|
|
81
|
+
}
|
|
82
|
+
return name;
|
|
83
|
+
};
|
|
84
|
+
const scales = (x, y, z) => {
|
|
85
|
+
const sx = s.rt.toNumber(x);
|
|
86
|
+
const sy = s.rt.toNumber(y);
|
|
87
|
+
const sz = s.rt.toNumber(z);
|
|
88
|
+
if (sx === 0 || sy === 0 || sz === 0) {
|
|
89
|
+
throw s.rt.error("ArgumentError", 2183);
|
|
90
|
+
}
|
|
91
|
+
return scale3D(sx, sy, sz);
|
|
92
|
+
};
|
|
93
|
+
const rotation = (degrees, axis, pivot) => rotation3D(s.rt.toNumber(degrees), read3D(nonNull(axis, "axis")), pivot === null || pivot === undefined ? [0, 0, 0] : read3D(pivot), s.rt.swfVersion >= 13);
|
|
94
|
+
class Matrix3DNatives {
|
|
95
|
+
"flash.geom:Matrix3D::ctor"(raw) {
|
|
96
|
+
const values = raw?.$a;
|
|
97
|
+
this.$matrix3D = values?.length === 16 ? Float32Array.from(values.map(Number)) : identity();
|
|
98
|
+
}
|
|
99
|
+
get rawData() {
|
|
100
|
+
return vector(data(this));
|
|
101
|
+
}
|
|
102
|
+
set rawData(raw) {
|
|
103
|
+
const values = raw?.$a;
|
|
104
|
+
if (values?.length === 16) {
|
|
105
|
+
data(this).set(values.map(Number));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
clone() {
|
|
109
|
+
const copy = s.rt.construct(s.rt.classNamed("flash.geom::Matrix3D"));
|
|
110
|
+
data(copy).set(data(this));
|
|
111
|
+
return copy;
|
|
112
|
+
}
|
|
113
|
+
copyFrom(source) {
|
|
114
|
+
if (source === null || source === undefined) {
|
|
115
|
+
throw s.rt.error("TypeError", 2007, "source");
|
|
116
|
+
}
|
|
117
|
+
data(this).set(data(source));
|
|
118
|
+
}
|
|
119
|
+
copyToMatrix3D(dest) {
|
|
120
|
+
if (dest === null || dest === undefined) {
|
|
121
|
+
throw s.rt.error("TypeError", 2007, "dest");
|
|
122
|
+
}
|
|
123
|
+
data(dest).set(data(this));
|
|
124
|
+
}
|
|
125
|
+
copyRawDataFrom(source, index = 0, transpose = false) {
|
|
126
|
+
if (source === null || source === undefined) {
|
|
127
|
+
throw s.rt.error("TypeError", 2007, "source");
|
|
128
|
+
}
|
|
129
|
+
const values = source.$a;
|
|
130
|
+
const start = s.rt.toUint(index);
|
|
131
|
+
if (start + 16 > values.length) {
|
|
132
|
+
throw s.rt.error("ArgumentError", 2004);
|
|
133
|
+
}
|
|
134
|
+
const m = data(this);
|
|
135
|
+
if (transpose) {
|
|
136
|
+
for (let i = 0; i < 16; i++) {
|
|
137
|
+
m[i] = Number(values[start + (i % 4) * 4 + (i >> 2)]);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
for (let i = 0; i < 16; i++) {
|
|
142
|
+
m[i] = Number(values[start + i]);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
copyRawDataTo(dest, index = 0, transpose = false) {
|
|
147
|
+
if (dest === null || dest === undefined) {
|
|
148
|
+
throw s.rt.error("TypeError", 2007, "dest");
|
|
149
|
+
}
|
|
150
|
+
const vector = dest;
|
|
151
|
+
const values = vector.$a;
|
|
152
|
+
const start = s.rt.toUint(index);
|
|
153
|
+
// Below this adl pads the vector out to the index, however far; from it, a negative index too, it refuses.
|
|
154
|
+
if (start >= MAX_INDEX) {
|
|
155
|
+
throw s.rt.error("ArgumentError", 2004);
|
|
156
|
+
}
|
|
157
|
+
if (vector.$fixed && start + 16 > values.length) {
|
|
158
|
+
throw s.rt.error("RangeError", 1126);
|
|
159
|
+
}
|
|
160
|
+
while (values.length < start + 16) {
|
|
161
|
+
values.push(0);
|
|
162
|
+
}
|
|
163
|
+
const m = data(this);
|
|
164
|
+
for (let i = 0; i < 16; i++) {
|
|
165
|
+
values[start + i] = m[transpose ? (i % 4) * 4 + (i >> 2) : i];
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
copyRowTo(row, dest) {
|
|
169
|
+
const n = checkedAxis(dest, row);
|
|
170
|
+
const m = data(this);
|
|
171
|
+
for (let i = 0; i < 4; i++) {
|
|
172
|
+
s.rt.setProperty(dest, s.rt.publicName(axes[i]), m[n + i * 4]);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
copyColumnTo(column, dest) {
|
|
176
|
+
const n = checkedAxis(dest, column);
|
|
177
|
+
const m = data(this);
|
|
178
|
+
for (let i = 0; i < 4; i++) {
|
|
179
|
+
s.rt.setProperty(dest, s.rt.publicName(axes[i]), m[n * 4 + i]);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
copyRowFrom(row, source) {
|
|
183
|
+
const n = checkedAxis(source, row);
|
|
184
|
+
const m = data(this);
|
|
185
|
+
for (let i = 0; i < 4; i++) {
|
|
186
|
+
m[n + i * 4] = s.rt.toNumber(s.rt.getProperty(source, s.rt.publicName(axes[i])));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
copyColumnFrom(column, source) {
|
|
190
|
+
const n = checkedAxis(source, column);
|
|
191
|
+
const m = data(this);
|
|
192
|
+
for (let i = 0; i < 4; i++) {
|
|
193
|
+
m[n * 4 + i] = s.rt.toNumber(s.rt.getProperty(source, s.rt.publicName(axes[i])));
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
identity() {
|
|
197
|
+
data(this).set(identity());
|
|
198
|
+
}
|
|
199
|
+
transpose() {
|
|
200
|
+
const m = data(this);
|
|
201
|
+
for (let row = 0; row < 4; row++) {
|
|
202
|
+
for (let col = row + 1; col < 4; col++) {
|
|
203
|
+
const a = row * 4 + col;
|
|
204
|
+
const b = col * 4 + row;
|
|
205
|
+
const value = m[a];
|
|
206
|
+
m[a] = m[b];
|
|
207
|
+
m[b] = value;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
appendTranslation(x, y, z) {
|
|
212
|
+
const m = data(this);
|
|
213
|
+
m[12] += Math.fround(s.rt.toNumber(x));
|
|
214
|
+
m[13] += Math.fround(s.rt.toNumber(y));
|
|
215
|
+
m[14] += Math.fround(s.rt.toNumber(z));
|
|
216
|
+
}
|
|
217
|
+
prependTranslation(x, y, z) {
|
|
218
|
+
const t = translation3D(s.rt.toNumber(x), s.rt.toNumber(y), s.rt.toNumber(z));
|
|
219
|
+
data(this).set(multiply3D(data(this), t));
|
|
220
|
+
}
|
|
221
|
+
appendScale(x, y, z) {
|
|
222
|
+
data(this).set(multiply3D(scales(x, y, z), data(this)));
|
|
223
|
+
}
|
|
224
|
+
prependScale(x, y, z) {
|
|
225
|
+
data(this).set(multiply3D(data(this), scales(x, y, z)));
|
|
226
|
+
}
|
|
227
|
+
appendRotation(degrees, axis, pivot = null) {
|
|
228
|
+
data(this).set(multiply3D(rotation(degrees, axis, pivot), data(this)));
|
|
229
|
+
}
|
|
230
|
+
prependRotation(degrees, axis, pivot = null) {
|
|
231
|
+
data(this).set(multiply3D(data(this), rotation(degrees, axis, pivot)));
|
|
232
|
+
}
|
|
233
|
+
append(lhs) {
|
|
234
|
+
data(this).set(multiply3D(data(nonNull(lhs, "lhs")), data(this)));
|
|
235
|
+
}
|
|
236
|
+
prepend(rhs) {
|
|
237
|
+
data(this).set(multiply3D(data(this), data(nonNull(rhs, "rhs"))));
|
|
238
|
+
}
|
|
239
|
+
/** Of the opposite sign before SWF 13, as adl has it. */
|
|
240
|
+
get determinant() {
|
|
241
|
+
const d = determinant3D(data(this));
|
|
242
|
+
return s.rt.swfVersion >= 13 ? d : -d;
|
|
243
|
+
}
|
|
244
|
+
invert() {
|
|
245
|
+
const inverse = invert3D(data(this));
|
|
246
|
+
if (inverse) {
|
|
247
|
+
data(this).set(inverse);
|
|
248
|
+
}
|
|
249
|
+
return inverse !== null;
|
|
250
|
+
}
|
|
251
|
+
get position() {
|
|
252
|
+
const m = data(this);
|
|
253
|
+
return vector3D(m[12], m[13], m[14], 0);
|
|
254
|
+
}
|
|
255
|
+
set position(v) {
|
|
256
|
+
if (v === null || v === undefined) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
const [x, y, z] = read3D(v);
|
|
260
|
+
const m = data(this);
|
|
261
|
+
m[12] = x;
|
|
262
|
+
m[13] = y;
|
|
263
|
+
m[14] = z;
|
|
264
|
+
}
|
|
265
|
+
// Both round the vector to float32 first; transformVectors works in doubles.
|
|
266
|
+
transformVector(v) {
|
|
267
|
+
const [x, y, z, w] = transform3D(data(this), ...xyz(nonNull(v, "vector")));
|
|
268
|
+
return vector3D(x, y, z, w);
|
|
269
|
+
}
|
|
270
|
+
deltaTransformVector(v) {
|
|
271
|
+
const [x, y, z, w] = transform3D(data(this), ...xyz(nonNull(v, "vector")), 0);
|
|
272
|
+
return vector3D(x, y, z, w);
|
|
273
|
+
}
|
|
274
|
+
transformVectors(vin, vout) {
|
|
275
|
+
const input = nonNull(vin, "vin").$a;
|
|
276
|
+
const output = nonNull(vout, "vout");
|
|
277
|
+
const n = Math.floor(input.length / 3) * 3;
|
|
278
|
+
if (n > output.$a.length) {
|
|
279
|
+
if (output.$fixed) {
|
|
280
|
+
throw s.rt.error("RangeError", 1126, output.$a.length, n);
|
|
281
|
+
}
|
|
282
|
+
while (output.$a.length < n) {
|
|
283
|
+
output.$a.push(0);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
const m = Array.from(data(this));
|
|
287
|
+
for (let i = 0; i < n; i += 3) {
|
|
288
|
+
const x = Number(input[i]);
|
|
289
|
+
const y = Number(input[i + 1]);
|
|
290
|
+
const z = Number(input[i + 2]);
|
|
291
|
+
output.$a[i] = m[0] * x + m[4] * y + m[8] * z + m[12];
|
|
292
|
+
output.$a[i + 1] = m[1] * x + m[5] * y + m[9] * z + m[13];
|
|
293
|
+
output.$a[i + 2] = m[2] * x + m[6] * y + m[10] * z + m[14];
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
pointAt(pos, at = null, up = null) {
|
|
297
|
+
const turned = pointAt3D(data(this), xyz(nonNull(pos, "position")), at === null || at === undefined ? [0, 1, 0] : xyz(at), up === null || up === undefined ? [0, 0, 1] : xyz(up));
|
|
298
|
+
if (turned) {
|
|
299
|
+
data(this).set(turned);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
decompose(style = "eulerAngles") {
|
|
303
|
+
const parts = decompose3D(data(this), orientation(style));
|
|
304
|
+
const cls = s.rt.applyType(s.rt.classNamed("__AS3__.vec::Vector"), [
|
|
305
|
+
s.rt.classNamed("flash.geom::Vector3D"),
|
|
306
|
+
]);
|
|
307
|
+
const o = cls.$it.instance();
|
|
308
|
+
o.$a = parts.map(([x, y, z, w]) => vector3D(x, y, z, w));
|
|
309
|
+
return o;
|
|
310
|
+
}
|
|
311
|
+
/** False, the matrix left as it was, for fewer than three components or a null one. */
|
|
312
|
+
recompose(components, style = "eulerAngles") {
|
|
313
|
+
const list = nonNull(components, "components").$a;
|
|
314
|
+
const how = orientation(style);
|
|
315
|
+
const parts = list.slice(0, 3);
|
|
316
|
+
if (parts.length < 3 || parts.some((p) => p === null || p === undefined)) {
|
|
317
|
+
return false;
|
|
318
|
+
}
|
|
319
|
+
const [t, r, sc] = parts.map((p) => read3D(p));
|
|
320
|
+
data(this).set(compose3D(t, r, sc, how));
|
|
321
|
+
return true;
|
|
322
|
+
}
|
|
323
|
+
interpolateTo(to, percent) {
|
|
324
|
+
const target = data(nonNull(to, "toMat"));
|
|
325
|
+
data(this).set(interpolate3D(data(this), target, s.rt.toNumber(percent)));
|
|
326
|
+
}
|
|
327
|
+
static interpolate(from, to, percent) {
|
|
328
|
+
const a = data(nonNull(from, "fromMat"));
|
|
329
|
+
const b = data(nonNull(to, "toMat"));
|
|
330
|
+
return matrix3D(interpolate3D(a, b, s.rt.toNumber(percent)));
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
// A display object's own Matrix3D (Transform's matrix3D) shares its matrix: one changed in place
|
|
334
|
+
// has the object take it apart again, as it moves the object in Flash.
|
|
335
|
+
const told = (o) => {
|
|
336
|
+
const owner = o?.$owner;
|
|
337
|
+
owner?.matrix3DChanged(data(o));
|
|
338
|
+
};
|
|
339
|
+
const proto = Matrix3DNatives.prototype;
|
|
340
|
+
for (const name of CHANGES) {
|
|
341
|
+
const d = Object.getOwnPropertyDescriptor(proto, name);
|
|
342
|
+
if (d.set) {
|
|
343
|
+
const set = d.set;
|
|
344
|
+
d.set = function (v) {
|
|
345
|
+
set.call(this, v);
|
|
346
|
+
told(this);
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
else {
|
|
350
|
+
const method = d.value;
|
|
351
|
+
d.value = function (...args) {
|
|
352
|
+
const result = method.apply(this, args);
|
|
353
|
+
told(this);
|
|
354
|
+
return result;
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
Object.defineProperty(proto, name, d);
|
|
358
|
+
}
|
|
359
|
+
avm2.registerNativeClass(natives, "flash.geom::Matrix3D", Matrix3DNatives);
|
|
360
|
+
return natives;
|
|
361
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// flash.geom.PerspectiveProjection: a field of view and a centre, of its
|
|
2
|
+
// own or, got from a Transform, of its display object, which it then
|
|
3
|
+
// reads and writes. The stage and each SWF's root always have one, back to
|
|
4
|
+
// their defaults when set to null. What is in a display object with one
|
|
5
|
+
// is drawn through it (display/perspective.ts).
|
|
6
|
+
import { avm2 } from "../../../../runtime/index.js";
|
|
7
|
+
import { TRANSFORM } from "../../../display/display.js";
|
|
8
|
+
import { defaultProjection, focalLengthOver as focalLength } from "../../../display/perspective.js";
|
|
9
|
+
const DEGREES_TO_RADIANS = Math.PI / 180;
|
|
10
|
+
/** Whether `d` has a projection whatever a script sets: the stage, or a SWF's root. */
|
|
11
|
+
export function alwaysProjects(s, d) {
|
|
12
|
+
return d === s.stage || d.loaderInfo !== null;
|
|
13
|
+
}
|
|
14
|
+
/** The projection `d` has: its own, or the default the stage, a root, or a projection's reader falls back on. */
|
|
15
|
+
function projectionOf(s, d) {
|
|
16
|
+
if (d.projection) {
|
|
17
|
+
return d.projection;
|
|
18
|
+
}
|
|
19
|
+
const root = d !== s.stage && d.loaderInfo !== null;
|
|
20
|
+
return root
|
|
21
|
+
? defaultProjection(s.stageWidth / 2, s.stageHeight / 2)
|
|
22
|
+
: defaultProjection(250, 250);
|
|
23
|
+
}
|
|
24
|
+
export function perspectiveProjectionNatives(s) {
|
|
25
|
+
const natives = {};
|
|
26
|
+
/** The stage's projection and one of its own measure 500 wide; any other object's, the stage's width. */
|
|
27
|
+
const width = (d) => (d && d !== s.stage ? s.stageWidth : 500);
|
|
28
|
+
const focalOf = (o) => o.$display
|
|
29
|
+
? focalLength(projectionOf(s, o.$display).fieldOfView, width(o.$display))
|
|
30
|
+
: focalLength(o.$fieldOfView * DEGREES_TO_RADIANS, 500);
|
|
31
|
+
class PerspectiveProjectionNatives {
|
|
32
|
+
"flash.geom:PerspectiveProjection::ctor"() {
|
|
33
|
+
this.$display = null;
|
|
34
|
+
this.$fieldOfView = 55;
|
|
35
|
+
this.$centerX = 250;
|
|
36
|
+
this.$centerY = 250;
|
|
37
|
+
}
|
|
38
|
+
get fieldOfView() {
|
|
39
|
+
if (this.$display) {
|
|
40
|
+
return (projectionOf(s, this.$display).fieldOfView * 180) / Math.PI;
|
|
41
|
+
}
|
|
42
|
+
return this.$fieldOfView;
|
|
43
|
+
}
|
|
44
|
+
set fieldOfView(v) {
|
|
45
|
+
const degrees = s.rt.toNumber(v);
|
|
46
|
+
if (!(degrees > 0 && degrees < 180)) {
|
|
47
|
+
throw s.rt.error("ArgumentError", 2182);
|
|
48
|
+
}
|
|
49
|
+
if (this.$display) {
|
|
50
|
+
update(this.$display, { fieldOfView: (degrees * Math.PI) / 180 });
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
this.$fieldOfView = degrees;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
get focalLength() {
|
|
57
|
+
return focalOf(this);
|
|
58
|
+
}
|
|
59
|
+
set focalLength(v) {
|
|
60
|
+
const length = s.rt.toNumber(v);
|
|
61
|
+
if (!(length > 0)) {
|
|
62
|
+
throw s.rt.error("ArgumentError", 2186, length);
|
|
63
|
+
}
|
|
64
|
+
const radians = Math.atan(width(this.$display) / 2 / length) * 2;
|
|
65
|
+
if (this.$display) {
|
|
66
|
+
update(this.$display, { fieldOfView: radians });
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
this.$fieldOfView = (radians * 180) / Math.PI;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
get projectionCenter() {
|
|
73
|
+
const p = this.$display ? projectionOf(s, this.$display) : null;
|
|
74
|
+
return s.rt.construct(s.rt.classNamed("flash.geom::Point"), p ? p.centerX : this.$centerX, p ? p.centerY : this.$centerY);
|
|
75
|
+
}
|
|
76
|
+
set projectionCenter(v) {
|
|
77
|
+
if (v === null || v === undefined) {
|
|
78
|
+
throw s.rt.error("TypeError", 2007, "projectionCenter");
|
|
79
|
+
}
|
|
80
|
+
const point = v;
|
|
81
|
+
const x = s.rt.toNumber(s.rt.getProperty(point, s.rt.publicName("x")));
|
|
82
|
+
const y = s.rt.toNumber(s.rt.getProperty(point, s.rt.publicName("y")));
|
|
83
|
+
if (this.$display) {
|
|
84
|
+
update(this.$display, { centerX: x, centerY: y });
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
this.$centerX = x;
|
|
88
|
+
this.$centerY = y;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
toMatrix3D() {
|
|
92
|
+
const length = focalOf(this);
|
|
93
|
+
const m = s.rt.construct(s.rt.classNamed("flash.geom::Matrix3D"));
|
|
94
|
+
m.$matrix3D.set([length, 0, 0, 0, 0, length, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0]);
|
|
95
|
+
return m;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/** A change to a display object's projection, made from its current one. */
|
|
99
|
+
const update = (d, change) => {
|
|
100
|
+
d.projection = { ...projectionOf(s, d), ...change };
|
|
101
|
+
d.invalidate(TRANSFORM);
|
|
102
|
+
};
|
|
103
|
+
avm2.registerNativeClass(natives, "flash.geom::PerspectiveProjection", PerspectiveProjectionNatives);
|
|
104
|
+
return natives;
|
|
105
|
+
}
|
|
106
|
+
/** A PerspectiveProjection of `d`'s, which reads and writes `d`'s. */
|
|
107
|
+
export function projectionObject(s, d) {
|
|
108
|
+
const o = s.rt.construct(s.rt.classNamed("flash.geom::PerspectiveProjection"));
|
|
109
|
+
o.$display = d;
|
|
110
|
+
return o;
|
|
111
|
+
}
|
|
112
|
+
/** What setting `o` on a transform gives: a copy of its values, in radians. */
|
|
113
|
+
export function projectionFrom(s, o) {
|
|
114
|
+
if (o.$display) {
|
|
115
|
+
return { ...projectionOf(s, o.$display) };
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
fieldOfView: (o.$fieldOfView * Math.PI) / 180,
|
|
119
|
+
centerX: o.$centerX,
|
|
120
|
+
centerY: o.$centerY,
|
|
121
|
+
};
|
|
122
|
+
}
|