resium icon indicating copy to clipboard operation
resium copied to clipboard

polyline component adds material property, error occurs

Open computeone opened this issue 1 year ago • 5 comments

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)

computeone avatar May 21 '23 17:05 computeone

How about this?

const material = useMemo(() => Material.fromType(Material.ColorType, { ... }), []);

// ...

<Polyline material={material} />

rot1024 avatar Jun 05 '23 09:06 rot1024

This will still report an error because the material was destroyed when removed

computeone avatar Jun 06 '23 11:06 computeone

using useMemo doesn't work, it still reports an error

computeone avatar Jun 27 '23 00:06 computeone

This is a bug not a question!

computeone avatar Jul 03 '23 06:07 computeone

Any update for this issue ? I have same error like screenshot below: image image

eksant avatar Dec 19 '23 08:12 eksant