Skip to content

Commit

Permalink
Add clip rect example
Browse files Browse the repository at this point in the history
  • Loading branch information
rossning92 committed Sep 5, 2022
1 parent 8b4d816 commit 8a857fb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/examples/basic/clip-rect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as mo from 'movy';

const g = mo.addGroup();
g.addCircle({ scale: 4 });
g.setClipRect({ width: 3.5, height: 3.5 });
6 changes: 3 additions & 3 deletions src/movy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1804,7 +1804,7 @@ class SceneObject {

setClipRect(params: AddRectParameters = {}): SceneObject {
promise = promise.then(async () => {
const { width = 1, height = 1 } = params;
const { x = 0, y = 0, width = 1, height = 1 } = params;

const clippingPlanes = [
new Plane(new Vector3(1, 0, 0), 1),
Expand All @@ -1818,8 +1818,8 @@ class SceneObject {
material.clippingPlanes = clippingPlanes;
});

const worldPosition = new Vector3();
this.object3D.getWorldPosition(worldPosition);
const worldPosition = new Vector3(x, y, 0);
this.object3D.localToWorld(worldPosition);
const worldScale = new Vector3();
this.object3D.getWorldScale(worldScale);

Expand Down

0 comments on commit 8a857fb

Please sign in to comment.