Working with Watermark

Contents
[ ]

Create a 3D Scene

First you need to create a 3d scene from a 3d file.The following code snippet shows how to use this functionality:

var aspose = aspose || {};

aspose.threed = require("aspose.3d");

var scene = aspose.threed.Scene.fromFile("template.3ds");

Encode Watermark

Aspose.3D adds watermark text information and watermark password to 3d files through the encodeWatermark method. The following code snippet shows how to use this functionality:

var aspose = aspose || {};

aspose.threed = require("aspose.3d");

// Walks the node tree and encodes the blind watermark into every mesh found
function encodeWatermark(node) {
    var entity = node.getEntity();
    if (entity instanceof aspose.threed.Mesh) {
        var watermarked = aspose.threed.Watermark.encodeWatermark(entity, "HelloWorld", "1234");
        if (watermarked != null) {
            node.setEntity(watermarked);
        }
    }
    var children = node.getChildNodes();
    for (var i = 0; i < children.size(); i++) {
        encodeWatermark(children.get(i));
    }
}

// Encode a blind watermark into every mesh of the scene
encodeWatermark(scene.getRootNode());

Save Document

You can save to any 3d file format you want.The following code snippet shows how to use this functionality:

scene.save("output.fbx", aspose.threed.FileFormat.FBX7400ASCII);