@archvisioninc/canvas 3.1.5 → 3.1.6
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.
|
@@ -139,8 +139,6 @@ const applyUVSettings = args => {
|
|
|
139
139
|
texture.vScale = uvYScale;
|
|
140
140
|
}
|
|
141
141
|
};
|
|
142
|
-
|
|
143
|
-
// TODO: Future uses should support red, green, blue, and alpha channels with defaults for each
|
|
144
142
|
const updateTextureChannel = (imageToMaintain, newImage, channelToUpdate) => {
|
|
145
143
|
const maintainHeight = imageToMaintain?.naturalHeight ?? 0;
|
|
146
144
|
const maintainWidth = imageToMaintain?.naturalWidth ?? 0;
|
|
@@ -167,11 +165,11 @@ const updateTextureChannel = (imageToMaintain, newImage, channelToUpdate) => {
|
|
|
167
165
|
const combinedImageData = ctx.createImageData(maxWidth, maxHeight);
|
|
168
166
|
const combinedData = combinedImageData.data;
|
|
169
167
|
for (let i = 0; i < combinedData.length; i += 4) {
|
|
170
|
-
const maintainRed = maintainData ? maintainData[i] :
|
|
168
|
+
const maintainRed = maintainData ? maintainData[i] : 1;
|
|
171
169
|
const maintainGreen = maintainData ? maintainData[i + 1] : 0;
|
|
172
170
|
const maintainBlue = maintainData ? maintainData[i + 2] : 0;
|
|
173
171
|
const maintainAlpha = maintainData ? maintainData[i + 3] : 255;
|
|
174
|
-
const newRed = newData ? newData[i] :
|
|
172
|
+
const newRed = newData ? newData[i] : 1;
|
|
175
173
|
const newGreen = newData ? newData[i + 1] : 0;
|
|
176
174
|
const newBlue = newData ? newData[i + 2] : 0;
|
|
177
175
|
const newAlpha = newData ? newData[i + 3] : 255;
|
|
@@ -397,6 +395,8 @@ export const updateMaterial = inboundData => {
|
|
|
397
395
|
const [metallicImage, currentImage] = data;
|
|
398
396
|
const combinedTexture = updateTextureChannel(currentImage, metallicImage, 'B');
|
|
399
397
|
currentTexture.updateURL(combinedTexture);
|
|
398
|
+
material.useRoughnessFromMetallicTextureAlpha = false;
|
|
399
|
+
material.useMetalnessFromMetallicTextureBlue = true;
|
|
400
400
|
texture.dispose();
|
|
401
401
|
applyUVSettings({
|
|
402
402
|
texture: material.metallicTexture,
|
|
@@ -438,6 +438,8 @@ export const updateMaterial = inboundData => {
|
|
|
438
438
|
const [roughnessImage, metallicImage] = data;
|
|
439
439
|
const combinedTexture = updateTextureChannel(metallicImage, roughnessImage, 'G');
|
|
440
440
|
currentTexture.updateURL(combinedTexture);
|
|
441
|
+
material.useRoughnessFromMetallicTextureAlpha = false;
|
|
442
|
+
material.useRoughnessFromMetallicTextureGreen = true;
|
|
441
443
|
texture.dispose();
|
|
442
444
|
applyUVSettings({
|
|
443
445
|
texture: material.metallicTexture,
|
package/package.json
CHANGED
|
@@ -177,7 +177,6 @@ const applyUVSettings = args => {
|
|
|
177
177
|
}
|
|
178
178
|
};
|
|
179
179
|
|
|
180
|
-
// TODO: Future uses should support red, green, blue, and alpha channels with defaults for each
|
|
181
180
|
const updateTextureChannel = (imageToMaintain, newImage, channelToUpdate) => {
|
|
182
181
|
const maintainHeight = imageToMaintain?.naturalHeight ?? 0;
|
|
183
182
|
const maintainWidth = imageToMaintain?.naturalWidth ?? 0;
|
|
@@ -212,12 +211,12 @@ const updateTextureChannel = (imageToMaintain, newImage, channelToUpdate) => {
|
|
|
212
211
|
const combinedData = combinedImageData.data;
|
|
213
212
|
|
|
214
213
|
for (let i = 0; i < combinedData.length; i += 4) {
|
|
215
|
-
const maintainRed = maintainData ? maintainData[i] :
|
|
214
|
+
const maintainRed = maintainData ? maintainData[i] : 1;
|
|
216
215
|
const maintainGreen = maintainData ? maintainData[i + 1] : 0;
|
|
217
216
|
const maintainBlue = maintainData ? maintainData[i + 2] : 0;
|
|
218
217
|
const maintainAlpha = maintainData ? maintainData[i + 3] : 255;
|
|
219
218
|
|
|
220
|
-
const newRed = newData ? newData[i] :
|
|
219
|
+
const newRed = newData ? newData[i] : 1;
|
|
221
220
|
const newGreen = newData ? newData[i + 1] : 0;
|
|
222
221
|
const newBlue = newData ? newData[i + 2] : 0;
|
|
223
222
|
const newAlpha = newData ? newData[i + 3] : 255;
|
|
@@ -231,7 +230,6 @@ const updateTextureChannel = (imageToMaintain, newImage, channelToUpdate) => {
|
|
|
231
230
|
ctx.putImageData(combinedImageData, 0, 0);
|
|
232
231
|
|
|
233
232
|
return canvas.toDataURL('image/png');
|
|
234
|
-
|
|
235
233
|
};
|
|
236
234
|
|
|
237
235
|
// eslint-disable-next-line
|
|
@@ -455,6 +453,8 @@ export const updateMaterial = inboundData => {
|
|
|
455
453
|
const [ metallicImage, currentImage ] = data;
|
|
456
454
|
const combinedTexture = updateTextureChannel(currentImage, metallicImage, 'B');
|
|
457
455
|
currentTexture.updateURL(combinedTexture);
|
|
456
|
+
material.useRoughnessFromMetallicTextureAlpha = false;
|
|
457
|
+
material.useMetalnessFromMetallicTextureBlue = true;
|
|
458
458
|
|
|
459
459
|
texture.dispose();
|
|
460
460
|
applyUVSettings({ texture: material.metallicTexture, material });
|
|
@@ -495,6 +495,8 @@ export const updateMaterial = inboundData => {
|
|
|
495
495
|
const [ roughnessImage, metallicImage ] = data;
|
|
496
496
|
const combinedTexture = updateTextureChannel(metallicImage, roughnessImage, 'G');
|
|
497
497
|
currentTexture.updateURL(combinedTexture);
|
|
498
|
+
material.useRoughnessFromMetallicTextureAlpha = false;
|
|
499
|
+
material.useRoughnessFromMetallicTextureGreen = true;
|
|
498
500
|
|
|
499
501
|
texture.dispose();
|
|
500
502
|
applyUVSettings({ texture: material.metallicTexture, material });
|
package/src/scenes/App/App.js
CHANGED
|
@@ -130,8 +130,9 @@ const App = () => {
|
|
|
130
130
|
const onImageLoad = args => {
|
|
131
131
|
const inboundData = {
|
|
132
132
|
payload: {
|
|
133
|
-
id: 'Material
|
|
133
|
+
id: 'Material #38',
|
|
134
134
|
metallicTexture: args,
|
|
135
|
+
|
|
135
136
|
},
|
|
136
137
|
};
|
|
137
138
|
|
|
@@ -149,6 +150,28 @@ const App = () => {
|
|
|
149
150
|
});
|
|
150
151
|
};
|
|
151
152
|
|
|
153
|
+
const onRoughnessImageLoad = args => {
|
|
154
|
+
const inboundData = {
|
|
155
|
+
payload: {
|
|
156
|
+
id: 'Material #38',
|
|
157
|
+
roughnessTexture: args,
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
updateMaterial(inboundData);
|
|
162
|
+
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const handleRoughnessUpload = e => {
|
|
166
|
+
const file = e.currentTarget.files[0];
|
|
167
|
+
const reader = new FileReader();
|
|
168
|
+
reader.readAsDataURL(file);
|
|
169
|
+
reader.onload = () => onRoughnessImageLoad({
|
|
170
|
+
name: file.name,
|
|
171
|
+
src: reader.result,
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
|
|
152
175
|
useEffect(() => {
|
|
153
176
|
getPreviewURL();
|
|
154
177
|
}, [ getPreviewURL ]);
|
|
@@ -201,7 +224,7 @@ const App = () => {
|
|
|
201
224
|
onClick={() => {
|
|
202
225
|
const inboundData = {
|
|
203
226
|
payload: {
|
|
204
|
-
id: 'Material
|
|
227
|
+
id: 'Material #38',
|
|
205
228
|
removeRoughnessTexture: true,
|
|
206
229
|
},
|
|
207
230
|
};
|
|
@@ -213,11 +236,21 @@ const App = () => {
|
|
|
213
236
|
</Button>
|
|
214
237
|
|
|
215
238
|
<input
|
|
239
|
+
name='Metallic'
|
|
240
|
+
title='Metallic'
|
|
216
241
|
type={'file'}
|
|
217
242
|
onChange={handleUpload}
|
|
218
243
|
accept={'image/*'}
|
|
219
244
|
/>
|
|
220
245
|
|
|
246
|
+
<input
|
|
247
|
+
name='Roughness'
|
|
248
|
+
title='Roughness'
|
|
249
|
+
type={'file'}
|
|
250
|
+
onChange={handleRoughnessUpload}
|
|
251
|
+
accept={'image/*'}
|
|
252
|
+
/>
|
|
253
|
+
|
|
221
254
|
<Button
|
|
222
255
|
theme={theme}
|
|
223
256
|
$selectedTheme={selectedTheme}
|