# How to Embed and Rotate 3D Models (.GLB Files) in PowerPoint Presentations Using OfficeCLI

> Easily embed and rotate 3D GLB models in PowerPoint with OfficeCLI. Learn to leverage Open XML packages and XML attributes for seamless presentation integration. Get started now.

- Repository: [OfficeAI/OfficeCLI](https://github.com/iofficeai/OfficeCLI)
- Tags: how-to-guide
- Published: 2026-08-09

---

**OfficeCLI treats PowerPoint files as Open XML packages, allowing you to embed glTF-Binary (.glb) models as ExtendedParts and control their rotation via XML attributes using the `add` and `set` commands.**

OfficeCLI, developed by iOfficeAI, enables programmatic manipulation of PowerPoint presentations through the Open XML standard. When working with 3D content, the CLI specifically targets the **glTF-Binary (.glb)** format to embed rich 3D models directly into slide packages. This article explains the complete pipeline—from validation to rotation—based on the actual source implementation in the iOfficeAI/OfficeCLI repository.

## How OfficeCLI Processes 3D GLB Models

OfficeCLI follows a strict pipeline when handling 3D assets, ensuring compatibility with PowerPoint's rendering engine while maintaining package integrity.

### File Validation and ExtendedPart Creation

The entry point for 3D operations resides in [`PowerPointHandler.Add.Model3D.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/PowerPointHandler.Add.Model3D.cs). Before embedding, the CLI validates that the source file carries a `.glb` extension; any other format triggers an `ArgumentException` at lines 20-39. Once validated, the binary stream is stored as an **ExtendedPart** using the `Model3dRelType` content type (lines 48-51), which preserves the raw glTF data within the Open XML package structure.

### Thumbnail Generation for Fallback Rendering

Simultaneously with the binary embedding, OfficeCLI generates a PNG thumbnail from the 3D model and stores it as a standard `ImagePart`. This ensures that presentation software unable to render native 3D objects—such as older PowerPoint versions or mobile viewers—displays a static placeholder instead of a broken object.

### Building the model3d XML Element

The actual slide reference is constructed in the `BuildModel3DElement` method (lines 231-243 of [`PowerPointHandler.Add.Model3D.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/PowerPointHandler.Add.Model3D.cs)). This method generates the `<model3d>` XML element that links both the `.glb` ExtendedPart and its thumbnail, while encoding dimensional properties including size and position coordinates.

## Embedding GLB Files with the Add Command

To insert a 3D model into a specific slide, use the `add` command with the `model3d` type. The CLI requires the `src` property pointing to your `.glb` file, alongside positioning parameters.

```bash

# Add a model to slide 1, centered at 2cm from top-left, 8cm x 8cm size

officecli add slide 1 model3d \
  --prop src=./models/rocket.glb \
  --prop name=Rocket \
  --prop cx=8 --prop cy=8 \
  --prop left=2 --prop top=2

```

**Key parameters:**
- `src`: Path to the **.glb** file (validated as glTF-Binary)
- `cx`/`cy`: Width and height in centimeters
- `left`/`top`: Position offsets from the slide's top-left corner
- `name`: Identifier for subsequent operations

This command invokes `AddModel3D` in [`PowerPointHandler.Add.Model3D.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/PowerPointHandler.Add.Model3D.cs), which orchestrates the validation, ExtendedPart creation, and XML element generation described above.

## Rotating 3D Models Using the Set Command

Rotation is applied post-embedding through the `set` command, which modifies the `<model3d>` element's orientation attributes. The CLI accepts rotation as a comma-delimited string `ax,ay,az` representing degrees around the X, Y, and Z axes.

In [`PowerPointHandler.Set.Media.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/PowerPointHandler.Set.Media.cs), the `SetModel3DByPath` method (lines 696-704) parses the `rotation` property and writes the values into the XML attributes `rotX`, `rotY`, and `rotZ`.

```bash

# Rotate the model 30° on X-axis, 0° on Y-axis, 45° on Z-axis

officecli set slide 1 model3d \
  --prop rotation=30,0,45 \
  --prop name=Rocket

```

The rotation string follows the format **pitch,yaw,roll**, allowing precise control over the model's orientation within the slide coordinate system.

## Previewing 3D Models Before Export

OfficeCLI provides an HTML preview capability that renders slides using Three.js, enabling visual verification of rotation and placement without opening PowerPoint. During preview generation, [`PowerPointHandler.HtmlPreview.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/PowerPointHandler.HtmlPreview.cs) calls `ResetModel3DRenderState` (lines 80-88) to clear cached geometries before applying the stored rotation values to the Three.js renderer.

```bash

# Complete workflow: add, rotate, and preview

officecli add slide 2 model3d \
  --prop src=./models/planet.glb \
  --prop name=Planet \
  --prop cx=10 --prop cy=10 \
  --prop left=1 --prop top=1

officecli set slide 2 model3d \
  --prop rotation=0,45,0 \
  --prop name=Planet

officecli preview slide 2

```

The preview engine processes the ExtendedPart and applies the `rotX`, `rotY`, and `rotZ` attributes to generate a browser-based visualization that matches the final PowerPoint rendering.

## Summary

- OfficeCLI validates **.glb** files exclusively in [`PowerPointHandler.Add.Model3D.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/PowerPointHandler.Add.Model3D.cs), rejecting other 3D formats at lines 20-39.
- Models are stored as **ExtendedParts** (`Model3dRelType`) with accompanying PNG thumbnails for backward compatibility.
- The `BuildModel3DElement` method (lines 231-243) constructs the `<model3d>` XML element linking the binary data and visual properties.
- Rotation values are parsed from comma-delimited strings and written to `rotX`, `rotY`, and `rotZ` attributes via `SetModel3DByPath` in [`PowerPointHandler.Set.Media.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/PowerPointHandler.Set.Media.cs).
- HTML previews use Three.js to render models with cached state reset via `ResetModel3DRenderState` in [`PowerPointHandler.HtmlPreview.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/PowerPointHandler.HtmlPreview.cs).

## Frequently Asked Questions

### What file formats does OfficeCLI support for 3D models?

OfficeCLI exclusively supports the **glTF-Binary (.glb)** format for 3D model embedding. The validation logic in [`PowerPointHandler.Add.Model3D.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/PowerPointHandler.Add.Model3D.cs) explicitly checks file extensions and throws an `ArgumentException` for any non-GLB input. This restriction ensures compatibility with PowerPoint's native 3D rendering engine.

### How do I specify rotation angles in OfficeCLI?

Specify rotation using the `rotation` property with a comma-separated string in the format `X,Y,Z` (pitch, yaw, roll). For example, `rotation=30,0,45` rotates the model 30 degrees around the X-axis and 45 degrees around the Z-axis. The `SetModel3DByPath` method in [`PowerPointHandler.Set.Media.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/PowerPointHandler.Set.Media.cs) parses this string into individual XML attributes.

### Why does my PowerPoint show a thumbnail instead of the 3D model?

OfficeCLI generates a PNG thumbnail for every embedded 3D model to serve as a fallback. If your PowerPoint version predates 3D model support (Office 2019/Microsoft 365) or if 3D rendering is disabled, the application displays the thumbnail ImagePart instead of the interactive model. The thumbnail is created during the initial `add` operation alongside the ExtendedPart.

### Can I update the position of a 3D model after embedding it?

Yes, use the `set` command with the `model3d` type and reference the model by its `name` property. You can modify positional attributes such as `left`, `top`, `cx`, and `cy` using the same syntax as the rotation update. The CLI updates the corresponding XML attributes in the slide's `<model3d>` element without requiring re-embedding of the binary data.