cubeforge 0.4.3 → 0.4.5

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/dist/index.d.ts CHANGED
@@ -3,8 +3,8 @@ import * as React from 'react';
3
3
  import React__default, { CSSProperties, ReactNode, ReactElement } from 'react';
4
4
  import { Plugin, EntityId, ECSWorld, ScriptUpdateFn, NavGrid, WorldSnapshot, EventBus, AccessibilityOptions } from '@cubeforge/core';
5
5
  export { AccessibilityOptions, AssetProgress, Component, ECSWorld, Ease, EntityId, GameTimer, HierarchyComponent, HierarchySystem, HotReloadablePlugin, MergedRect, NavGrid, Plugin, PreloadManifest, ScriptUpdateFn, SpatialHash, TimelineEntry, TransformComponent, TweenHandle, TweenTimeline, Vec2Like, WorldSnapshot, WorldTransformComponent, announceToScreenReader, arrive, createHierarchy, createTag, createTimeline, createTimer, createTransform, definePlugin, findByTag, flee, getAccessibilityOptions, getDescendants, hmrClearState, hmrLoadState, hmrSaveState, hotReloadPlugin, mergeTileColliders, patrol, preloadManifest, removeParent, seek, setAccessibilityOptions, setParent, tween, wander } from '@cubeforge/core';
6
- import { Sampling, BlendMode, AnimatorStateDefinition, AnimatorParamValue, GradientType, GradientStop, MaskShape, PostProcessEffect } from '@cubeforge/renderer';
7
- export { AnimationClipDefinition, AnimationStateComponent, AnimatorComponent, AnimatorCondition, AnimatorParamValue, AnimatorStateDefinition, AnimatorTransition, BlendMode, CircleShapeComponent, GradientComponent, GradientStop, GradientType, LineShapeComponent, MagFilterValue, MaskComponent, MaskShape, NineSliceComponent, ParallaxLayerComponent, Particle, ParticlePoolComponent, PolygonShapeComponent, PostProcessEffect, PostProcessStack, RenderLayer, RenderLayerManager, RenderSystem, Sampling, SpriteComponent, SquashStretchComponent, TextComponent, TextureFilter, TextureFilterValue, TrailComponent, chromaticAberrationEffect, createCircleShape, createGradient, createLineShape, createMask, createNineSlice, createPolygonShape, createPostProcessStack, createRenderLayerManager, createSprite, defaultLayers, scanlineEffect, vignetteEffect } from '@cubeforge/renderer';
6
+ import { Sampling, BlendMode, SpriteShape, AnimatorStateDefinition, AnimatorParamValue, GradientType, GradientStop, MaskShape, PostProcessEffect } from '@cubeforge/renderer';
7
+ export { AnimationClipDefinition, AnimationStateComponent, AnimatorComponent, AnimatorCondition, AnimatorParamValue, AnimatorStateDefinition, AnimatorTransition, BlendMode, CircleShapeComponent, GradientComponent, GradientStop, GradientType, LineShapeComponent, MagFilterValue, MaskComponent, MaskShape, NineSliceComponent, ParallaxLayerComponent, Particle, ParticlePoolComponent, PolygonShapeComponent, PostProcessEffect, PostProcessStack, RenderLayer, RenderLayerManager, RenderSystem, Sampling, SpriteComponent, SpriteShape, SquashStretchComponent, TextComponent, TextureFilter, TextureFilterValue, TrailComponent, chromaticAberrationEffect, createCircleShape, createGradient, createLineShape, createMask, createNineSlice, createPolygonShape, createPostProcessStack, createRenderLayerManager, createSprite, defaultLayers, scanlineEffect, vignetteEffect } from '@cubeforge/renderer';
8
8
  import { CombineRule, ColliderShape, JointType } from '@cubeforge/physics';
9
9
  export { AxisLock, BVH, BoxColliderComponent, BroadPhaseAABB, BroadPhasePair, COLLISION_DYNAMIC_DYNAMIC, COLLISION_DYNAMIC_KINEMATIC, COLLISION_DYNAMIC_STATIC, COLLISION_KINEMATIC_KINEMATIC, COLLISION_KINEMATIC_STATIC, CapsuleColliderComponent, CharacterCollision, CharacterController, CharacterControllerConfig, CircleColliderComponent, ColliderShape, CollisionPair, CollisionPipeline, CollisionPipelineResult, CombineRule, CompoundColliderComponent, ContactManifold, ContactPoint, ConvexPolygonColliderComponent, ConvexShape, DEFAULT_ACTIVE_COLLISION_TYPES, DebugCircle, DebugLine, DebugPoint, DebugRenderBackend, DebugRenderColors, DebugRenderFlags, DebugRenderOutput, DebugRenderPipeline, EPAResult, Float64Pool, GJKContactManifold, GJKResult, HalfSpaceColliderComponent, HeightFieldColliderComponent, Island, IslandDetector, JointComponent, JointMotor, JointSnapshot, JointType, KahanSum, MotorMode, MoveResult, MultibodyArticulation, MultibodyLink, PhysicsBodySnapshot, PhysicsHooks, ObjectPool as PhysicsObjectPool, PhysicsSnapshot, PointProjection, QueryOpts, QueryShape, RaycastHit, RigidBodyComponent, SegmentColliderComponent, Spatial3, SpatialInertia3, SweepAndPrune, TOIBody, TOIResult, TriMeshColliderComponent, Triangle2D, TriangleColliderComponent, addForce, addForceAtPoint, addTorque, applyImpulse, applyImpulseAtPoint, applyTorqueImpulse, boxArea, boxShape, buildBVH, capsuleArea, capsuleShape, circleArea, circleShape, computeTOI, containsPoint, createCompoundCollider, createConvexPolygonCollider, createHalfSpaceCollider, createHeightFieldCollider, createJoint, createLink, createMultibody, createSegmentCollider, createTriMeshCollider, createTriangleCollider, dMath, deterministicAtan2, deterministicCos, deterministicSin, deterministicSqrt, epa, generateDeterministicPairs, gjk, gjkEpaQuery, intersectAABB, intersectRay, intersectShape, isDeterministicMode, kineticEnergy, overlapBox, overlapCircle, pairKey, polygonArea, polygonMassProperties, polygonShape, potentialEnergy, predictPosition, projectPoint, queryBVH, queryBVHCircle, raycast, raycastAll, recomputeMassFromColliders, resetAllPools, resetForces, resetTorques, resolveTOI, restoreSnapshot, setAdditionalMass, setDeterministicMode, setMassProperties, setNextKinematicPosition, setNextKinematicRotation, shapeCast, snapshotFromBytes, snapshotFromJSON, snapshotHash, snapshotToBytes, snapshotToJSON, sortEntities, sweepBox, takeSnapshot, triangleArea, triangleMassProperties, velocityAtPoint } from '@cubeforge/physics';
10
10
  import { InputManager, ActionBindings, InputContextName, PlayerInput, InputRecorderControls, TouchPoint, InputBufferOptions, InputBuffer, ComboDefinition } from '@cubeforge/input';
@@ -135,8 +135,22 @@ interface SpriteProps {
135
135
  tintOpacity?: number;
136
136
  /** Overall opacity 0-1 (default 1) */
137
137
  opacity?: number;
138
+ /** Shape to draw: 'rect' (default), 'circle', 'ellipse', 'roundedRect', 'triangle', 'star', 'pentagon', 'hexagon' */
139
+ shape?: SpriteShape;
140
+ /** Border radius for 'roundedRect' shape (px) */
141
+ borderRadius?: number;
142
+ /** Stroke outline color */
143
+ strokeColor?: string;
144
+ /** Stroke outline width in pixels */
145
+ strokeWidth?: number;
146
+ /** Custom draw callback */
147
+ customDraw?: (ctx: CanvasRenderingContext2D, width: number, height: number) => void;
148
+ /** Number of points for 'star' shape (default 5) */
149
+ starPoints?: number;
150
+ /** Inner radius ratio for 'star' shape (0-1, default 0.4) */
151
+ starInnerRadius?: number;
138
152
  }
139
- declare function Sprite({ width, height, color, src, offsetX, offsetY, zIndex, visible, flipX, flipY, anchorX, anchorY, frameIndex, frameWidth, frameHeight, frameColumns, atlas, frame, tileX, tileY, tileSizeX, tileSizeY, sampling, blendMode, layer, tint, tintOpacity, opacity, }: SpriteProps): null;
153
+ declare function Sprite({ width, height, color, src, offsetX, offsetY, zIndex, visible, flipX, flipY, anchorX, anchorY, frameIndex, frameWidth, frameHeight, frameColumns, atlas, frame, tileX, tileY, tileSizeX, tileSizeY, sampling, blendMode, layer, tint, tintOpacity, opacity, shape, borderRadius, strokeColor, strokeWidth, customDraw, starPoints, starInnerRadius, }: SpriteProps): null;
140
154
 
141
155
  interface TextProps {
142
156
  text: string;
package/dist/index.js CHANGED
@@ -1831,6 +1831,11 @@ function createSprite(opts) {
1831
1831
  blendMode: "normal",
1832
1832
  layer: "default",
1833
1833
  opacity: 1,
1834
+ shape: "rect",
1835
+ borderRadius: 0,
1836
+ strokeWidth: 0,
1837
+ starPoints: 5,
1838
+ starInnerRadius: 0.4,
1834
1839
  ...opts
1835
1840
  };
1836
1841
  }
@@ -2347,6 +2352,8 @@ var RenderSystem = class {
2347
2352
  gl.enable(gl.BLEND);
2348
2353
  gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
2349
2354
  }
2355
+ /** Default background used when no Camera2D component exists */
2356
+ defaultBackground = "#1a1a2e";
2350
2357
  gl;
2351
2358
  program;
2352
2359
  quadVAO;
@@ -2617,7 +2624,7 @@ var RenderSystem = class {
2617
2624
  const W = canvas.width;
2618
2625
  const H = canvas.height;
2619
2626
  let camX = 0, camY = 0, zoom = 1;
2620
- let background = "#000000";
2627
+ let background = this.defaultBackground;
2621
2628
  let shakeX = 0, shakeY = 0;
2622
2629
  const camId = world.queryOne("Camera2D");
2623
2630
  if (camId !== void 0) {
@@ -3264,7 +3271,7 @@ var Canvas2DRenderer = class {
3264
3271
  }
3265
3272
  ctx;
3266
3273
  clear(color) {
3267
- if (color) {
3274
+ if (color && color !== "transparent") {
3268
3275
  this.ctx.fillStyle = color;
3269
3276
  this.ctx.fillRect(0, 0, this.canvas.width, this.canvas.height);
3270
3277
  } else {
@@ -12720,7 +12727,14 @@ function Sprite({
12720
12727
  layer = "default",
12721
12728
  tint,
12722
12729
  tintOpacity,
12723
- opacity = 1
12730
+ opacity = 1,
12731
+ shape = "rect",
12732
+ borderRadius = 0,
12733
+ strokeColor,
12734
+ strokeWidth = 0,
12735
+ customDraw,
12736
+ starPoints = 5,
12737
+ starInnerRadius = 0.4
12724
12738
  }) {
12725
12739
  const resolvedFrameIndex = atlas && frame != null ? atlas[frame] ?? 0 : frameIndex;
12726
12740
  const engine = useContext6(EngineContext);
@@ -12762,7 +12776,14 @@ function Sprite({
12762
12776
  layer,
12763
12777
  tint,
12764
12778
  tintOpacity,
12765
- opacity
12779
+ opacity,
12780
+ shape,
12781
+ borderRadius,
12782
+ strokeColor,
12783
+ strokeWidth,
12784
+ customDraw,
12785
+ starPoints,
12786
+ starInnerRadius
12766
12787
  });
12767
12788
  engine.ecs.addComponent(entityId, comp);
12768
12789
  if (src) {
@@ -12790,6 +12811,13 @@ function Sprite({
12790
12811
  comp.tint = tint;
12791
12812
  comp.tintOpacity = tintOpacity;
12792
12813
  comp.opacity = opacity;
12814
+ comp.shape = shape;
12815
+ comp.borderRadius = borderRadius;
12816
+ comp.strokeColor = strokeColor;
12817
+ comp.strokeWidth = strokeWidth;
12818
+ comp.customDraw = customDraw;
12819
+ comp.starPoints = starPoints;
12820
+ comp.starInnerRadius = starInnerRadius;
12793
12821
  }, [
12794
12822
  color,
12795
12823
  visible,
@@ -12802,6 +12830,13 @@ function Sprite({
12802
12830
  tint,
12803
12831
  tintOpacity,
12804
12832
  opacity,
12833
+ shape,
12834
+ borderRadius,
12835
+ strokeColor,
12836
+ strokeWidth,
12837
+ customDraw,
12838
+ starPoints,
12839
+ starInnerRadius,
12805
12840
  engine,
12806
12841
  entityId
12807
12842
  ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cubeforge",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "description": "React-first 2D browser game engine",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",