3d-game-engine-canvas
Advanced tools
Comparing version 0.1.23 to 0.1.24
{ | ||
"name": "3d-game-engine-canvas", | ||
"version": "0.1.23", | ||
"version": "0.1.24", | ||
"type": "module", | ||
@@ -10,2 +10,3 @@ "scripts": { | ||
"deploy": "npm version --no-git-tag-version patch && npm run doc && npm publish", | ||
"patch": "npm version --no-git-tag-version patch", | ||
"doc": "typedoc --entryPointStrategy expand ./src" | ||
@@ -12,0 +13,0 @@ }, |
@@ -29,2 +29,6 @@ import Camera from "../../components/Camera"; | ||
/** | ||
* Called when component added to GameObject | ||
* @param obj GameObject | ||
*/ | ||
register(obj: GameObject) { | ||
@@ -34,2 +38,5 @@ this.gameObject = obj; | ||
/** | ||
* Destroy component | ||
*/ | ||
destroy() { | ||
@@ -41,8 +48,38 @@ this.gameObject.removeComponent(this); | ||
/** | ||
* Called on scene load | ||
*/ | ||
async awake() {} | ||
/** | ||
* Called when object is created | ||
*/ | ||
async start() {} | ||
/** | ||
* Called every frame before render | ||
*/ | ||
async update() {} | ||
/** | ||
* Called every frame after render | ||
*/ | ||
async lateUpdate() {} | ||
/** | ||
* Called when component is destroyed | ||
*/ | ||
async onDestroy() {} | ||
/** | ||
* Used for rendering | ||
* @param _renderer | ||
* @param _camera | ||
*/ | ||
render(_renderer: Renderer, _camera: Camera) {} | ||
/** | ||
* Used for rendering UI | ||
* @param _canvas | ||
*/ | ||
uiRender(_canvas: VirtualCanvas) {} | ||
@@ -49,0 +86,0 @@ |
@@ -269,5 +269,5 @@ import Component from "./Component"; | ||
const s = this._anchor.multiply( | ||
new Vector2(this.canvas.width, this.canvas.height) | ||
); | ||
const s = this._anchor | ||
.multiply(new Vector2(this.canvas.width, this.canvas.height)) | ||
.roundToInt(); | ||
const p = this.realPosition.subtract(s); | ||
@@ -274,0 +274,0 @@ |
@@ -45,2 +45,6 @@ import Texture from "../utilities/Texture"; | ||
0, | ||
c.canvas.width, | ||
c.canvas.height, | ||
0, | ||
0, | ||
this.uiElement.realSize.x, | ||
@@ -47,0 +51,0 @@ this.uiElement.realSize.y |
@@ -25,2 +25,7 @@ import SizedComponent from "../classes/Components/SizedComponent"; | ||
/** | ||
* Check if given vector is inside UiElement global box | ||
* @param v vector to check | ||
* @returns boolean | ||
*/ | ||
contains(v: Vector2): boolean { | ||
@@ -27,0 +32,0 @@ const s = this.realSize.divide(2); |
@@ -9,9 +9,19 @@ import SizedComponent from "../classes/Components/SizedComponent"; | ||
renderer: Renderer; | ||
scale: number; | ||
constructor(renderer: Renderer, layer: number, smoothing: boolean = true) { | ||
constructor( | ||
renderer: Renderer, | ||
scale: number, | ||
layer: number, | ||
smoothing: boolean = true | ||
) { | ||
super({ | ||
size: new Vector2(renderer.canvas.width, renderer.canvas.height), | ||
size: new Vector2( | ||
renderer.canvas.width * scale, | ||
renderer.canvas.height * scale | ||
), | ||
smoothing: smoothing, | ||
}); | ||
this.renderer = renderer; | ||
this.scale = scale; | ||
renderer.onResize.addEventListener(this.onResize.bind(this)); | ||
@@ -22,3 +32,6 @@ this.layer = layer; | ||
onResize(args: onResizeArgs) { | ||
this.size = new Vector2(args.width, args.height); | ||
this.size = new Vector2( | ||
args.width * this.scale, | ||
args.height * this.scale | ||
); | ||
} | ||
@@ -25,0 +38,0 @@ |
@@ -13,2 +13,7 @@ import { clamp } from "./Math"; | ||
/** | ||
* Clamps given Vector3 to be inside box | ||
* @param v Vector3 | ||
* @returns Vector3 | ||
*/ | ||
clamp(v: Vector3) { | ||
@@ -15,0 +20,0 @@ return new Vector3( |
@@ -13,2 +13,7 @@ import { clamp } from "./Math"; | ||
/** | ||
* Clamps given Vector2 to be inside box | ||
* @param v Vector2 | ||
* @returns Vector2 | ||
*/ | ||
clamp(v: Vector2) { | ||
@@ -29,2 +34,7 @@ return new Vector2( | ||
/** | ||
* Check if given Vector2 is inside box | ||
* @param v Vector2 | ||
* @returns boolean | ||
*/ | ||
contains(v: Vector2): boolean { | ||
@@ -31,0 +41,0 @@ return ( |
2003798
75
4298