Skip to content

Commit

Permalink
Merge pull request #224 from JujieX/cherryPick/boxSelect
Browse files Browse the repository at this point in the history
Feat: upgrade version
  • Loading branch information
JujieX authored Aug 17, 2023
2 parents 8b86d5f + 84487bd commit 8a2b778
Show file tree
Hide file tree
Showing 15 changed files with 33 additions and 24 deletions.
2 changes: 1 addition & 1 deletion packages/auxiliary-lines/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/engine-toolkit-auxiliary-lines",
"version": "1.0.0-beta.3",
"version": "1.0.0-beta.6",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
Expand Down
2 changes: 1 addition & 1 deletion packages/controls/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/engine-toolkit-controls",
"version": "1.0.0-beta.3",
"version": "1.0.0-beta.6",
"license": "MIT",
"publishConfig": {
"access": "public",
Expand Down
2 changes: 1 addition & 1 deletion packages/custom-material/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/engine-toolkit-custom-material",
"version": "1.0.0-beta.3",
"version": "1.0.0-beta.6",
"license": "MIT",
"scripts": {
"b:types": "tsc",
Expand Down
2 changes: 1 addition & 1 deletion packages/framebuffer-picker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/engine-toolkit-framebuffer-picker",
"version": "1.0.0-beta.3",
"version": "1.0.0-beta.6",
"license": "MIT",
"module": "dist/es/index.js",
"main": "dist/commonjs/browser.js",
Expand Down
29 changes: 19 additions & 10 deletions packages/framebuffer-picker/src/FramebufferPicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,38 +145,47 @@ export class FramebufferPicker extends Script {

private _readPixelFromRenderTarget(x: number, y: number, xEnd?: number, yEnd?: number): Uint8Array {
let pickPixel: Uint8Array, width: number, height: number;
this._getCoordOnRenderTarget(x, y);
const startCoord = this._getCoordOnRenderTarget(x, y);
const argsLength = arguments.length;

if (argsLength === 2) {
pickPixel = FramebufferPicker._pickPixel;
width = height = 1;
} else if (argsLength === 4) {
this._getCoordOnRenderTarget(xEnd, yEnd);
const endCoord = this._getCoordOnRenderTarget(xEnd, yEnd);

width = Math.abs(xEnd - x);
height = Math.abs(yEnd - y);
width = Math.abs(startCoord.x - endCoord.x);
height = Math.abs(startCoord.y - endCoord.y);

x = x < xEnd ? x : xEnd;
y = y < yEnd ? y : yEnd;
startCoord.x = startCoord.x < endCoord.x ? startCoord.x : endCoord.x;
startCoord.y = startCoord.y < endCoord.y ? startCoord.y : endCoord.y;

pickPixel = new Uint8Array(width * height * 4);
}
(<Texture2D>this._pickRenderTarget.getColorTexture()).getPixelBuffer(
startCoord.x,
startCoord.y,
width,
height,
0,
pickPixel
);

(<Texture2D>this._pickRenderTarget.getColorTexture()).getPixelBuffer(x, y, width, height, 0, pickPixel);
return pickPixel;
}

private _getCoordOnRenderTarget(x: number, y: number) {
private _getCoordOnRenderTarget(x: number, y: number): { x: number; y: number } {
const pickRenderTarget = this._pickRenderTarget;
const { canvas } = this.engine;

const viewport = this._camera.viewport;
const viewWidth = (viewport.z - viewport.x) * canvas.width;
const viewHeight = (viewport.w - viewport.y) * canvas.height;

x = Math.floor(((x - viewport.x) / viewWidth) * (pickRenderTarget.width - 1));
y = Math.floor((1 - (y - viewport.y) / viewHeight) * (pickRenderTarget.height - 1));
return {
x: Math.floor(((x - viewport.x) / viewWidth) * (pickRenderTarget.width - 1)),
y: Math.floor((1 - (y - viewport.y) / viewHeight) * (pickRenderTarget.height - 1))
};
}

private _getRendererByPixel(color: Uint8Array): Renderer {
Expand Down
2 changes: 1 addition & 1 deletion packages/galacean-engine-toolkit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/engine-toolkit",
"version": "1.0.0-beta.3",
"version": "1.0.0-beta.6",
"license": "MIT",
"scripts": {
"b:types": "tsc"
Expand Down
2 changes: 1 addition & 1 deletion packages/geometry-sketch/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/engine-toolkit-geometry-sketch",
"version": "1.0.0-beta.3",
"version": "1.0.0-beta.6",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
Expand Down
2 changes: 1 addition & 1 deletion packages/gizmo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/engine-toolkit-gizmo",
"version": "1.0.0-beta.3",
"version": "1.0.0-beta.6",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
Expand Down
2 changes: 1 addition & 1 deletion packages/input-logger/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/engine-toolkit-input-logger",
"version": "1.0.0-beta.3",
"version": "1.0.0-beta.6",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
Expand Down
2 changes: 1 addition & 1 deletion packages/lines/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/engine-toolkit-lines",
"version": "1.0.0-beta.3",
"version": "1.0.0-beta.6",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
Expand Down
2 changes: 1 addition & 1 deletion packages/navigation-gizmo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/engine-toolkit-navigation-gizmo",
"version": "1.0.0-beta.3",
"version": "1.0.0-beta.6",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
Expand Down
2 changes: 1 addition & 1 deletion packages/outline/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/engine-toolkit-outline",
"version": "1.0.0-beta.3",
"version": "1.0.0-beta.6",
"license": "MIT",
"module": "dist/es/index.js",
"main": "dist/commonjs/browser.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/skeleton-viewer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/engine-toolkit-skeleton-viewer",
"version": "1.0.0-beta.3",
"version": "1.0.0-beta.6",
"license": "MIT",
"scripts": {
"b:types": "tsc"
Expand Down
2 changes: 1 addition & 1 deletion packages/stats/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/engine-toolkit-stats",
"version": "1.0.0-beta.3",
"version": "1.0.0-beta.6",
"license": "MIT",
"scripts": {
"b:types": "tsc"
Expand Down
2 changes: 1 addition & 1 deletion packages/way-point/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/engine-toolkit-way-point",
"version": "1.0.0-beta.3",
"version": "1.0.0-beta.6",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
Expand Down

0 comments on commit 8a2b778

Please sign in to comment.