resium
resium copied to clipboard
polyline component adds material property, error occurs
import { Cartesian3, Color, Material, Transforms } from 'cesium';
import { CameraFlyTo, Polyline, PolylineCollection, Viewer } from 'resium';
export const Scene3D: React.FC = (): JSX.Element => {
const center = Cartesian3.fromDegrees(-75.59777, 40.03883);
const positions = [new Cartesian3(-75, 35, 0), new Cartesian3(-125, 35, 0), new Cartesian3(-125, 135, 0)];
return (
<Viewer full>
<PolylineCollection modelMatrix={Transforms.eastNorthUpToFixedFrame(center)}>
<Polyline
positions={positions}
material={Material.fromType(Material.ColorType, {
color: new Color(1, 0, 0, 1),
})}
/>
</PolylineCollection>
<CameraFlyTo duration={0} destination={Cartesian3.fromDegrees(-75.6, 40.04, 1000)} />
</Viewer>
);
};
DeveloperError: This object was destroyed, i.e., destroy() was called.
Error
at new DeveloperError (http://localhost:3000/cesium/Cesium.js:12583:13)
at Material.throwOnDestroyed (http://localhost:3000/cesium/Cesium.js:28943:13)
at createCommandLists (http://localhost:3000/cesium/Cesium.js:117007:29)
at PolylineCollection.update (http://localhost:3000/cesium/Cesium.js:116937:7)
at PrimitiveCollection.update (http://localhost:3000/cesium/Cesium.js:150713:22)
at updateAndRenderPrimitives (http://localhost:3000/cesium/Cesium.js:212549:23)
at executeCommandsInViewport (http://localhost:3000/cesium/Cesium.js:212401:5)
at Scene4.updateAndExecuteCommands (http://localhost:3000/cesium/Cesium.js:212219:7)
at render (http://localhost:3000/cesium/Cesium.js:212855:11)
at tryAndCatchError (http://localhost:3000/cesium/Cesium.js:212869:7)
How about this?
const material = useMemo(() => Material.fromType(Material.ColorType, { ... }), []);
// ...
<Polyline material={material} />
This will still report an error because the material was destroyed when removed
using useMemo doesn't work, it still reports an error
This is a bug not a question!
Any update for this issue ?
I have same error like screenshot below: