@colijnit/inphoto 300.1.2 → 300.1.3
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.
|
@@ -1398,16 +1398,24 @@ class InphotoSceneService {
|
|
|
1398
1398
|
this.camera.position.set(0, 0, 5);
|
|
1399
1399
|
this._prepLights();
|
|
1400
1400
|
this.renderer = new WebGLRenderer({ antialias: true });
|
|
1401
|
-
this.renderer.setSize(width, height);
|
|
1402
1401
|
this.renderer.setPixelRatio(window.devicePixelRatio);
|
|
1403
1402
|
this.renderer.outputColorSpace = SRGBColorSpace;
|
|
1404
1403
|
this.renderer.toneMapping = ACESFilmicToneMapping;
|
|
1405
1404
|
this.renderer.toneMappingExposure = 1.0;
|
|
1406
1405
|
this.renderer.localClippingEnabled = true;
|
|
1406
|
+
this.resize(width, height);
|
|
1407
1407
|
this.container.nativeElement.appendChild(this.renderer.domElement);
|
|
1408
1408
|
this.needsRender = true;
|
|
1409
1409
|
this._animate();
|
|
1410
1410
|
}
|
|
1411
|
+
resize(width, height) {
|
|
1412
|
+
this.imageWidth = width;
|
|
1413
|
+
this.imageHeight = height;
|
|
1414
|
+
this.renderer.setSize(width, height);
|
|
1415
|
+
this.camera.aspect = width / height;
|
|
1416
|
+
this.camera.updateProjectionMatrix();
|
|
1417
|
+
this.needsRender = true;
|
|
1418
|
+
}
|
|
1411
1419
|
getSceneAsImage() {
|
|
1412
1420
|
this.renderer.render(this.scene, this.camera);
|
|
1413
1421
|
return this.renderer.domElement.toDataURL("image/png");
|
|
@@ -3121,23 +3129,6 @@ class EditCanvasComponent {
|
|
|
3121
3129
|
this._saveCanvas();
|
|
3122
3130
|
this.dataService.canvasHasMask = this.dataService.hasAnyMask();
|
|
3123
3131
|
}
|
|
3124
|
-
_syncLayersFromData() {
|
|
3125
|
-
if (!this.ctx) {
|
|
3126
|
-
return;
|
|
3127
|
-
}
|
|
3128
|
-
const activeColors = new Set(this.dataService.progressingData.map(d => d.maskColor));
|
|
3129
|
-
this._maskLayers.forEach((_layer, color) => {
|
|
3130
|
-
if (!activeColors.has(color)) {
|
|
3131
|
-
this._maskLayers.delete(color);
|
|
3132
|
-
}
|
|
3133
|
-
else {
|
|
3134
|
-
this._replayColor(color);
|
|
3135
|
-
}
|
|
3136
|
-
});
|
|
3137
|
-
this._render();
|
|
3138
|
-
this._saveCanvas();
|
|
3139
|
-
this.dataService.canvasHasMask = this.dataService.hasAnyMask();
|
|
3140
|
-
}
|
|
3141
3132
|
clearCanvas() {
|
|
3142
3133
|
this._maskLayers.forEach((layer, color) => {
|
|
3143
3134
|
layer.ctx.clearRect(0, 0, layer.canvas.width, layer.canvas.height);
|
|
@@ -3152,9 +3143,7 @@ class EditCanvasComponent {
|
|
|
3152
3143
|
loadBackground() {
|
|
3153
3144
|
const img = new Image();
|
|
3154
3145
|
img.onload = () => {
|
|
3155
|
-
|
|
3156
|
-
canvas.width = img.naturalWidth;
|
|
3157
|
-
canvas.height = img.naturalHeight;
|
|
3146
|
+
this._applyCanvasSize(img.naturalWidth, img.naturalHeight);
|
|
3158
3147
|
this._backgroundImage = img;
|
|
3159
3148
|
this._resizeAndReplayLayers();
|
|
3160
3149
|
this._render();
|
|
@@ -3162,6 +3151,36 @@ class EditCanvasComponent {
|
|
|
3162
3151
|
img.crossOrigin = 'anonymous';
|
|
3163
3152
|
img.src = this._image;
|
|
3164
3153
|
}
|
|
3154
|
+
_applyCanvasSize(nativeWidth, nativeHeight) {
|
|
3155
|
+
const canvas = this.canvas.nativeElement;
|
|
3156
|
+
canvas.width = nativeWidth;
|
|
3157
|
+
canvas.height = nativeHeight;
|
|
3158
|
+
const containerW = canvas.parentElement.clientWidth ? canvas.parentElement.clientWidth : nativeWidth;
|
|
3159
|
+
const maxW = Math.min(nativeWidth, containerW, window.innerWidth);
|
|
3160
|
+
const maxH = Math.min(nativeHeight, window.innerHeight);
|
|
3161
|
+
const scale = Math.min(maxW / nativeWidth, maxH / nativeHeight);
|
|
3162
|
+
const displayW = nativeWidth * scale;
|
|
3163
|
+
const displayH = nativeHeight * scale;
|
|
3164
|
+
canvas.style.width = `${displayW}px`;
|
|
3165
|
+
canvas.style.height = `${displayH}px`;
|
|
3166
|
+
}
|
|
3167
|
+
_syncLayersFromData() {
|
|
3168
|
+
if (!this.ctx) {
|
|
3169
|
+
return;
|
|
3170
|
+
}
|
|
3171
|
+
const activeColors = new Set(this.dataService.progressingData.map(d => d.maskColor));
|
|
3172
|
+
this._maskLayers.forEach((_layer, color) => {
|
|
3173
|
+
if (!activeColors.has(color)) {
|
|
3174
|
+
this._maskLayers.delete(color);
|
|
3175
|
+
}
|
|
3176
|
+
else {
|
|
3177
|
+
this._replayColor(color);
|
|
3178
|
+
}
|
|
3179
|
+
});
|
|
3180
|
+
this._render();
|
|
3181
|
+
this._saveCanvas();
|
|
3182
|
+
this.dataService.canvasHasMask = this.dataService.hasAnyMask();
|
|
3183
|
+
}
|
|
3165
3184
|
_getLayer(color) {
|
|
3166
3185
|
const canvasEl = this.canvas.nativeElement;
|
|
3167
3186
|
let layer = this._maskLayers.get(color);
|
|
@@ -3178,8 +3197,8 @@ class EditCanvasComponent {
|
|
|
3178
3197
|
const canvasEl = this.canvas.nativeElement;
|
|
3179
3198
|
this._maskLayers.forEach((layer, color) => {
|
|
3180
3199
|
if (layer.canvas.width !== canvasEl.width || layer.canvas.height !== canvasEl.height) {
|
|
3181
|
-
layer.canvas.width = canvasEl.width;
|
|
3182
|
-
layer.canvas.height = canvasEl.height;
|
|
3200
|
+
layer.canvas.width = canvasEl.width;
|
|
3201
|
+
layer.canvas.height = canvasEl.height;
|
|
3183
3202
|
}
|
|
3184
3203
|
this._replayColor(color);
|
|
3185
3204
|
});
|
|
@@ -3273,8 +3292,6 @@ class EditCanvasComponent {
|
|
|
3273
3292
|
<div class="canvas-container">
|
|
3274
3293
|
<canvas
|
|
3275
3294
|
#canvas
|
|
3276
|
-
width="800"
|
|
3277
|
-
height="500"
|
|
3278
3295
|
(mousedown)="startDrawing($event)"
|
|
3279
3296
|
(mousemove)="draw($event)"
|
|
3280
3297
|
(mouseup)="stopDrawing()"
|
|
@@ -3293,8 +3310,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
3293
3310
|
<div class="canvas-container">
|
|
3294
3311
|
<canvas
|
|
3295
3312
|
#canvas
|
|
3296
|
-
width="800"
|
|
3297
|
-
height="500"
|
|
3298
3313
|
(mousedown)="startDrawing($event)"
|
|
3299
3314
|
(mousemove)="draw($event)"
|
|
3300
3315
|
(mouseup)="stopDrawing()"
|
|
@@ -7091,6 +7106,7 @@ class InphotoThreedSceneComponent {
|
|
|
7091
7106
|
const calculatedHeight = planeData.cameraData.imageHeight * widthRatio;
|
|
7092
7107
|
this._sceneService.imageWidth = canvasCurrentWidth;
|
|
7093
7108
|
this._sceneService.imageHeight = calculatedHeight;
|
|
7109
|
+
this._sceneService.resize(canvasCurrentWidth, calculatedHeight);
|
|
7094
7110
|
CameraUtils.updateCamera(this._sceneService.camera, this._sceneService.renderer, planeData.cameraData, canvasCurrentWidth);
|
|
7095
7111
|
const floorMesh = FloorUtils.createFloor(planeData.floorGeometry);
|
|
7096
7112
|
this._sceneService.addFloorToScene(floorMesh);
|
|
@@ -7104,6 +7120,15 @@ class InphotoThreedSceneComponent {
|
|
|
7104
7120
|
const loader = new THREE.TextureLoader();
|
|
7105
7121
|
loader.load(url, (texture) => {
|
|
7106
7122
|
texture.colorSpace = THREE.SRGBColorSpace;
|
|
7123
|
+
const imgW = texture.image.width;
|
|
7124
|
+
const imgH = texture.image.height;
|
|
7125
|
+
const containerW = this.container.nativeElement.clientWidth;
|
|
7126
|
+
const targetW = Math.min(imgW, containerW);
|
|
7127
|
+
const targetH = targetW * (imgH / imgW);
|
|
7128
|
+
this._sceneService.renderer.setSize(targetW, targetH);
|
|
7129
|
+
this._sceneService.imageWidth = targetW;
|
|
7130
|
+
this._sceneService.imageHeight = targetH;
|
|
7131
|
+
CameraUtils.updateCamera(this._sceneService.camera, this._sceneService.renderer, this.room.floorPlaneMap.cameraData, targetW);
|
|
7107
7132
|
this._sceneService.scene.background = texture;
|
|
7108
7133
|
this._sceneService.needsRender = true;
|
|
7109
7134
|
});
|